Dear all AS/400 Lovers!
I need to add a pre-determined number of blank-spaces to each field, before adding it to a big flat-string.
I need to keep on concatenating different field-values to this big string.
But the field-values comes as "trimmed" values.
(i.e. in a 60-char-length address field, I may receive only 15-char address). Hence i cannot concatenate them directly & send it.
My requirement is: I need to pass the exact-length of each field into the flat-string, or else the data will get jumbled OR moved in hapazzard-way, as it is finnally moved into a Datastructure.
Any suggestion would be of great help. pls. let me know.
Thanks in advance,
Svanky
(i.e. in a 60-char-length address field, I may receive only 15-char address)
It's not clear what you mean by using the word "receive". Receive how? Please show an example of "receiving" a field.
Tom
Tom,
"Receive" - means, I receive another flat-string(which is not of exact length of that of target-string, which i need to create) which i break down into different fields & receive them in respective work-fields.
and finally concatenate them to create the "Final-String" to be sent.
here is the catch:-..
But while sending, I need to pass the exact-length of each field into the flat-string, or else the data will get jumbled, as this string will be finally moved into a Datastructure in another program, which i dont have control on.
Thanks,
Svanky.
which i break down into different fields & receive them in respective work-fields.
Make your work fields the same size as those needed in the final string, then concatenate them together to create the final string.
Since the other program will use a DataStructure to access the fields, why not simply use the same DS definition in your program? Pass the DS as the parameter after you put the values in.
Tom
d f1 s 30 inz('Ajax Inc.')
d f2 s 15 inz('Somewhere Road')
d f3 s 20 inz('Anytown')
d longfield s 1024
d space s 1 inz(' ')
c/free
longfield = 'AB' + space +
f1+ space +
f2 + space +
'xx4711' + space +
f3;
*inLR = *on;
A modified example using a DS to specify "exact lengths and positions":
d myDS ds
d f1 30 inz('Ajax Inc.')
d f2 15 inz('Somewhere Road')
d f3 20 inz('Anytown')
d longfield s 1024
/free
longfield = myDS ;
*inLR = *on;
/end-free
If you need exact lengths and positions. then simply code them the way they need to be. It might even be simpler coding of the C-specs if longfield was defined as *BASED over the DS (or vice versa). Then it wouldn't even need to be in an assignment statement to copy the DS. Or simply pass the DS in place of longfield.
Tom
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 7  Replies