|
View previous topic :: View next topic
|
| Author |
Message |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
Hi,
I have file (fb,80) where could be combination of AA or BB or CC or DD in any position ( only one combination per record) . Is it possible to change 3 position before combination to 111 if it is 000 there.
Input
| Code: |
00000000000000000AA111111111111111111
22222222BB000000000000000000000
CC0000000000000000000000
000000000000000000000000000DD111111111
|
Output:
| Code: |
00000000000000111AA111111111111111111
22222222BB000000000000000000000
CC0000000000000000000000
000000000000000000000000111DD111111111
|
|
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
| Sorry, I read my post and understood, that you will probably suggest me to use FINDREP function .... but real case more complicated, then I define it initially ...in general - I need to work /change 3 position before combination of AA,BB,CC,DD |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Can you tell us:
What is 'sertan'?? Do you mean to say 'certain' ??
What is your issue with FINDREP? Why can't you use that? What is real case which is supposed to be more complicated?
. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Are you saying that there must be 4 records present (1 x AA, 1 x BB, 1 x CC and 1 x DD) before you can change 000AA to 111AA in that group of four?
If so, will there only be four records in the group to be changed? |
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
sorry, it was typo with certain ...
I am saying that if combination of AA is in the record, then not other combinations as BB, CC etc in this record...
I cannot use FINDREP 000AA to 111AA because it is more complicated - it is not just change 000 to 111 ... it is in my request, but I need idea how to change 3 positions before combination .... it is not just 000 to 111 ...maybe better to explain .... I need to change 3 position before AA to 111 if this 3 positions NOT = 000 ... could be 123 or 321 or 1g1 ... so I cannot use FINDREP |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
You'll need to use PARSE to break your record into possibly 4 parts,
something similar to (not tested so may not be exactly what you want):
| Code: |
INREC PARSE=(%00=(ENDBEFR=C'AA',FIXLEN=80),
%01=(SUBPOS=5,ENDBEFR=C'AA',FIXLEN=3),
%02=(STARTAFT=C'AA',FIXLEN=80)),
BUILD=(%00,%01,C'AA',%02) |
And then you can user OVERLAY to whatever condition you want on '000' or 'Not 000'. similar to:
| Code: |
OUTREC IFTHEN=(WHEN=(81,3,CH,NE,C'000',AND,84,2,CH,EQ,C'AA'),
OVERLAY=(81:C'111')) |
I am in a rush but I hope this may give you some idea.
. |
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
| Thank you, I will try |
|
| Back to top |
|
 |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
Your condition is little confusing, any way below code may give you some insight.
Assuming LRECL=40
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C' ',C'~'))),
IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDAT=C'AA',
ENDAT=C'BB',
ENDAT=C'CC',
ENDAT=C'DD',
FIXLEN=40),
%02=(FIXLEN=40)),
BUILD=(%01,JFY=(SHIFT=RIGHT),%02)),
IFTHEN=(WHEN=(39,2,SS,EQ,C'AA,BB,CC,DD',AND,
36,3,CH,NE,C'000'),
OVERLAY=(36:C'111'))
OUTREC IFTHEN=(WHEN=INIT,
BUILD=(1,80,SQZ=(SHIFT=LEFT))),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'~',C' '))),
IFOUTLEN=40
|
output :
| Code: |
00000000000000000AA111111111111111111
22222111BB000000000000000000000
111CC0000000000000000000000
000000000000000000000000000DD111111111
|
|
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
| wow, looks great ... I 'll try to understand it line by line.... thank you , it's very nice idea |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|