Page 1 of 1

How to increment the value.

PostPosted: Mon Apr 28, 2014 6:06 pm
by samurai
Hello,

Could someone help me in incrementing the value from A01 -> A02

code:

"ALLOC FI(V5NAME) DA('"||OUT'('INN.I')'||"')SHR"
"EXECIO * DISKW V5NAME(STEM ICD. FINIS"
"FREE FI(V5NAME)"

here OUT is the output PDS and INN.I is member name

Actual member name is PUWMBA01, i need to write it as PUWMBA02.. Please help!!

Re: How to increment the value.

PostPosted: Mon Apr 28, 2014 6:10 pm
by prino
Split, increment and concatenate back.

Sheesh, was that so difficult?

Re: How to increment the value.

PostPosted: Mon Apr 28, 2014 7:12 pm
by samurai
i can split using SUBSTR as

INN.i = SUBSTR(INPUT_MEM.K,1,5)

and also split

ver = substr(input_mem.k,6,3) this will give A01
ver = ver + 1
may i know to increment????

"ALLOC FI(V5NAME) DA('"||OUT'(mem || ver)'||"')SHR" ----> this didnt work !! please correct me

Re: How to increment the value.

PostPosted: Mon Apr 28, 2014 7:22 pm
by samurai
Sorry Prino....I didnt think in another way ;)

Tried by cutting till number and now am able to increment :)
MEM = SUBSTR(INPUT_MEM.K,1,7)
INC = SUBSTR(INPUT_MEM.K,7,2)
INC = INC + 1
SAY INC


it Worked ...Thanks !!

Re: How to increment the value.

PostPosted: Mon Apr 28, 2014 10:33 pm
by Pedro
When you convert from alphabetic characters to numeric values, be careful not to lose the leading zero.

Re: How to increment the value.

PostPosted: Tue Apr 29, 2014 10:01 am
by samurai
Yeah it worked fine.NP. Thanks!

Re: How to increment the value.

PostPosted: Wed Sep 07, 2016 2:47 pm
by kir_910
Can you please paste the entire code you used to increment.

I have a requirement, wherein I have to save members toa PDS as PBDRBK01 ,02 and so on upto 30
I am not getting how to increment from 01 to 09, my rexx take as 1-9 instead of 01 to 09

Re: How to increment the value.

PostPosted: Wed Sep 07, 2016 3:22 pm
by NicC
Please do not tail-gate an old topic. Start a new one.