I have a PS file with length 80. I have 10 byte character data from column 70. now I have to count the char data for any characters apart from spaces and put the length in my varchar field. how can I do it in sort.
please post any example sort card on how to achieve this.
We cannot do that in single step, but with couple of steps it is possible, if I understood your problem statement in a right way! Assuming that the CHAR(10) starts from 71 to 80 and the length field from 69 to 70.
I'm sorry if I am unable to explain properly. I am trying to move a character field to a varchar field throught sortcard.
ex:
input file:
ABC
ABCDEFGI
AJDFAJ
In the above file my pic x(10) field has data less than 10 bytes as well. so, now im trying to move it to varchar(10) field through sort. I wrote the below sort card.
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:X'000A',
3:71,10)
however im trying to see If I can count the number of chars in the filed and put it in the length part of varchar field.
ex:
first line of input has 3 characters. so, X'0003' should be moved to the length.
please help me if we can achieve that counting part in the sort card.
The step 1 does that exactly. It moves the CHAR(10) to VB file by trimming trailing spaces. Again the VB data is converted into FB and from the RDW the length is calculated. The final output of step 1 has the VARCHAR equivalent of the CHAR(10) from the input file. Try running the job with your input, study the output files, you will get to know what it does.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Mounika Nemani,
If you have only one field that you are trying to find the data length of, and it is just 10 bytes then probably you can do this in one step with a bunch of IFTHENs evaluating the trailing blanks and find the data length.
EDIT: You might want to add another IFTHEN after the very first IFTHEN BUILD above, to look for all spaces and then subtract 10 if you are expecting all blanks in the input field.