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.
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 *
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.
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.
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.