Issue with concatenation



IBM's Command List programming language & Restructured Extended Executor

Issue with concatenation

Postby chenky » Tue Nov 20, 2012 5:21 pm

Hello,

I am beginner in REXX and want to concatenate a string for an array.

if i = 1 then do
queue "//SYSUT1 DD DSN="||inpi.i||"tested"

the part which is bolded is not seen in the input.

I am getting output as //SYSUT1 DD DSN=HY.JJ.U102.C1304.R02

where I have a list 0f 100 files in a dataset and each inpi.i(n) represent each file in that dataset.

But my requirement is //SYSUT1 DD DSN=HY.JJ.U102.C1304.R02tested
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Issue with concatenation

Postby Pedro » Tue Nov 20, 2012 7:25 pm

You did not show the origin of inpi.i, but you need to strip off the trailing blanks.
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Issue with concatenation

Postby chenky » Tue Nov 20, 2012 7:33 pm

Actually I have copied the paritail code..I am writting the REXX to create the JCL..

/********** rexx **************/
"free f(inpi)"
"free f(outo)"
/************************************************************/
say 'Please give Input file name'
pull inpfile
if inpfile = ' ' then do
say 'Inpfile cannot be spaces'
say 'Exit Program'
exit
end
"ALLOC DS('"inpfile"'),f(inpi) shr"
if rc /= 0 then do
say 'allocate Inp file unsuccessful with rc = ' rc
say 'cannot proceed. Exit Program'
exit
end
"execio * diskr inpi (stem inpi. finis"
/************************************************************/
say 'Please give seq no'
pull seqno
if seqno = ' ' then do
say 'seqno cannot be spaces'
say 'Exit Program'
exit
end
/************************************************************/
outputo = USERID()||'.gfiljcl.ext'||seqno
"delete ('"outputo"')"
"alloc ds('"outputo"') f(outo) new space(100,500) dsorg(ps)",
"recfm(f,b) lrecl(80)"
if rc/=0 then do
say 'allocate ms01out failed. rc ' rc
exit
end
qctr = 0
call procpara
call finalpara
"execio" qctr "diskw outo (finis"
exit
/************************************************************/
procpara:
queue "//IEBGEN"||seqno||" JOB (TESTS),'*TEST*',REGION=8500K,"
queue "// CLASS=Q,MSGCLASS=E,NOTIFY=&SYSUID"
queue "/*ROUTE PRINT SDSF"
queue "//* "
queue "//*--------------------------------------------------------"
queue "//* TO COPY 'ASSIGNED G FILES' DATA TO A SEQUENTIAL FILE "
queue "//*--------------------------------------------------------"
queue "//* "
queue "//S01IDCM EXEC PGM=IEBGENER"
queue "//SYSOUT DD SYSOUT=* "
queue "//SYSPRINT DD SYSOUT=* "
queue "//SYSIN DD * "
qctr = qctr + 12
do i = 1 to inpi.0
if i = 1 then do
queue "//SYSUT1 DD DSN="||inpi.i
queue '// DISP=SHR '
qctr = qctr + 2
iterate
qctr = qctr + 2
iterate
end
queue "// DD DSN="||inpi.i||','
queue "// DISP=SHR "
qctr = qctr + 2
end
return
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Issue with concatenation

Postby chenky » Tue Nov 20, 2012 7:39 pm

I tried by removing the trailing blanks..but i am not getting required O/P
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Issue with concatenation

Postby Pandora-Box » Tue Nov 20, 2012 7:57 pm

queue "//SYSUT1 DD DSN="||inpi.i


doesnt look like

queue "//SYSUT1 DD DSN="||inpi.i||"tested"
User avatar
Pandora-Box
 
Posts: 65
Joined: Fri Feb 10, 2012 8:30 pm
Location: Mars
Has thanked: 3 times
Been thanked: 6 times

Re: Issue with concatenation

Postby chenky » Tue Nov 20, 2012 8:03 pm

Hi Pandora,

queue "//SYSUT1 DD DSN="||inpi.i will give //SYSUT1 DD DSN=HY.JJ.U102.C1304.R02

But I want to have my output as //SYSUT1 DD DSN=HY.JJ.U102.C1304.R02tested

could you please provide me the code so that i will get output with tested word getting concatenated at the end :(
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Re: Issue with concatenation

Postby enrico-sorichetti » Tue Nov 20, 2012 8:43 pm

did You care to try to understand Pandora-box ' s post...
he already gave the code :evil:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Issue with concatenation

Postby NicC » Wed Nov 21, 2012 12:13 am

1) your job will fail - the JCL interpreter does not understand lower case so 'tested' is wrong
2) your job will fail - any one part of a dataset name cannot exceed 8 bytes - 'R02tested' is 9 bytes
3) your posted code consistently shows | | instead of || before 'tested'
4) post your code using the code tags as Pandora-Box did
5) Use trace to find out what is happening within your code.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Issue with concatenation

Postby Pedro » Wed Nov 21, 2012 3:11 am

Here is the last part of your code:
000055 qctr = qctr + 12                 
000056 do i = 1 to inpi.0               
000057 if i = 1 then do                 
000058 queue "//SYSUT1 DD DSN="||inpi.i 
000059 queue '// DISP=SHR '             
000060 qctr = qctr + 2                   
000061 iterate                           
000062 qctr = qctr + 2                   
000063 iterate                           
000064 end                               
000065 queue "// DD DSN="||inpi.i||','   
000066 queue "// DISP=SHR "             
000067 qctr = qctr + 2 end               
000068 return                             


* lines 58 and 65 are missing the 'TESTED' string that you covet.
* lines 61 and 62 seem superfluous.
* line 58 needs a comma at the end.
* the END at line 67 should have its own line.
* you add to QCTR, but can just use "EXECIO *", without having to know the number of lines

Elsewhere:
* finalpara is not defined.
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Issue with concatenation

Postby chenky » Wed Nov 21, 2012 1:06 pm

Hello all,

I have made all the changes as mentioned as below...

/********** rexx **************/                                 
"free f(inpi)"                                                   
"free f(outo)"                                                   
/************************************************************/   
say 'Please give Input file name'                               
pull inpfile                                                     
if inpfile = ' ' then do                                         
   say 'Inpfile cannot be spaces'                               
   say 'Exit Program'                                           
   exit                                                         
end                                                             
"ALLOC DS('"inpfile"'),f(inpi) shr"                             
if rc /= 0 then do                                               
   say 'allocate Inp file unsuccessful with rc = ' rc           
   say 'cannot proceed. Exit Program'                           
   exit                                                         
end                                                             
"execio * diskr inpi (stem inpi. finis"                         
/************************************************************/   
say 'Please give seq no'                                         
pull seqno                                                       
if seqno = ' ' then do                                           
   say 'seqno cannot be spaces'                                 
   say 'Exit Program'                                           
   exit                                                         
end                                                             
/************************************************************/   
outputo = USERID()||'.gfiljcl.ext'||seqno                       
"delete ('"outputo"')"                                           
"alloc ds('"outputo"') f(outo) new space(100,500) dsorg(ps)",   
"recfm(f,b) lrecl(80)"                                           
if rc/=0 then do                                                 
   say 'allocate ms01out failed. rc ' rc                         
   exit                                                         
end                                                             
qctr = 0                                                         
call procpara                                                   
call finalpara                                                   
"execio" qctr "diskw outo (finis"                               
exit                                                             
/************************************************************/   
procpara:                                                             
queue "//IEBGEN"||seqno||" JOB (D3DS),'*TEST*',REGION=8500K,"         
queue "//         CLASS=Q,MSGCLASS=E,NOTIFY=&SYSUID"                 
queue "/*ROUTE PRINT SDSF"                                           
queue "//*               "                                           
queue "//*--------------------------------------------------------"   
queue "//* TO COPY 'ASSIGNED  G  FILES' DATA TO A SEQUENTIAL FILE "   
queue "//*--------------------------------------------------------"   
queue "//*               "                                           
queue "//S01IDCM  EXEC PGM=IEBGENER"                                 
queue "//SYSOUT   DD SYSOUT=*      "                                 
queue "//SYSPRINT DD SYSOUT=*      "                                 
queue "//SYSIN    DD *             "                                 
qctr = qctr + 12                                                     
do i = 1 to inpi.0                                                   
[b]if i = 1 then do                                                     
queue "//SYSUT1   DD DSN="||inpi.i||"TST"                             
queue '//            DISP=SHR '                                       
qctr = qctr + 2                                                       
iterate                                                               
end                                   
queue "//         DD DSN="||inpi.i||"TST"                     
queue "//            DISP=SHR   "                             
qctr = qctr + 2                                               
end                                                        [/b]   
return                                                       
finalpara:                                                   
queue "//SYSUT2   DD DSN=SSTS.MSDXS.SDSA.MS1FLE1,"           
queue "//            DISP=(NEW,CATLG,DELETE),       "         
queue "//            UNIT=SYSALLDA,                 "         
queue "//            DCB=(RECFM=VB,LRECL=1028,BLKSIZE=27998),"
queue "//            SPACE=(CYL,(1500,1500),RLSE)            "
queue "//*"                                                   
qctr = qctr + 6                                               
return                                           


Unfortunately the TST is not present in my O/P :(

Code'd
chenky
 
Posts: 16
Joined: Tue Nov 20, 2012 4:59 pm
Has thanked: 7 times
Been thanked: 0 time

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post