I will be getting data in this format. But its not necessary that fields will contain full according to their length. Like Emp-key is of 10 byte but it can contain of 5 bytes data. So i need to write a sort card which will concatenate all fields in output file by '|' (pipe) and based on their data length output files' length must also vary. But it wont be greater than 104.
i.e
EMP-KEY(10)|EMP-NAME(30)|EMP-DESIGN-TEXT(20)|EMP-ADDRESS-TEXT(30)|EMP-SALARY
Also I hv to do vice-varsa.
I will be gettin file in above format of output file. So I need to write a sort card which will create file similart to the above input file containing LEN as well.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
What is in the "trailing" part of each field you want to chop? Do you have embedded spaces in names, or anything?
On the way "out" are you ignoring the binary fields, or would you prefer to use them to determine the lengths?
On the way "in" would you like the binary fields to be correct, or zero?
EDIT: We can assume that you meant "n bytes of data and 10-n bytes of "stuff" that you don't want on the Pipe file, but which you realise is convenient to have normally".
I mean,
If EMP-KEY(10) will contain 5 bytes data+5 trailing spaces then i want to ignore them and just want to concatenate 5 bytes of actual data.
Bill, I dont want to write binary fields in output but yes how it can be used in sort so that actual data(not trailing spaces) can be incuded in output.
Similary when i will receive a file which will contain '|' then at tht time i need to write the binary fields also in output which will contain the length.
I hope i hv done tht Bill...if you remeber my last post in cobol section few days back...!
And If you guys still think so, then sorry for tht. Will keep in mind. Thanks for informing
But I am still not able to sort out my issue.
I am not able to find the solution coz of Length.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
You would need to put "something" around the fields which can contain embedded blanks, and SQZ the record checking on the processing of QUOTE/APOST. Then convert it to variable-length.
Watch out for the possibility of your delimeter appearing in your data. Maybe to FINDREP to something like X'FF' and then reverse it after the SQZ.
The binary fields on the way back are trickier. It would be best to use the binary fields on the way out, but I'm not sure how :-)
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
Ashutosh,
you spend a lot of time (and space) defending yourself,
but you never supply any of the info asked for.
and what i was referring to was threads started by you,
questions asked in order to create a solution for you,
that you never answer, and the thread dies.
but i digress,
you want:
EMP-KEY(10)|EMP-NAME(30)|EMP-DESIGN-TEXT(20)|EMP-ADDRESS-TEXT(30)|EMP-SALARY
but spaces on the right truncated?
EMP-SALARY will always be 10 char numeric?
will this be generated as a Variable record file or Fixed length (104) record file?
as well as the converse?
again, answer the question of variable length and/or fixed length.
EMP-KEY|EMP-NAME|EMP-DESIGN-TEXT|EMP-ADDRESS-TEXT|EMP-SALARY
EMP-KEY expanded to 10
EMP-NAME expanded to 30
EMP-DESIGN-LEN generated as 2 bytes binary reflecting the length of data between the two | bounding EMP-DESIGN-TEXT
EMP-DESIGN-TEXT expanded to 20
EMP-ADDRESS-LEN generated as 2 bytes binary reflecting the length of data between the two | bounding EMP-ADDRESS-TEXT
EMP-ADDRESS-TEXT expanded to 30
EMP-SALARY copied as the 10 char
Dick,
As mentioned by you, yes I need my output as:
EMP-KEY(10)|EMP-NAME(30)|EMP-DESIGN-TEXT(20)|EMP-ADDRESS-TEXT(30)|EMP-SALARY
But the fields shudn't contain trailing spaces.
YES, EMP-SALARY will always contain 10 digit numeric data.
Output File can be created in VB with 104 length.
Say if all fields contain full data without spaces then whole 104 lenth would be full. If all length fields data without spaces + 4 pipes(|) is less than 104 then remaining positions after last field(EMP-SALARY) can be filled with spaces.
While for Vice versa
It will be other way round.
Either a field contains spaces or not it shud be included till its exact length.
Ex. EMP-KEY(10) contains 5 bytes data but next field shud be written from 11th position.
LEN field will contain the length of field containing actual data without spaces. EMP-ADDRESS-TEXT(30) contains 15 bytes data then LEN will be 15.
RECFM will be FB with LRECL of 104.
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
Quote:
Output File can be created in VB with 104 length.
Say if all fields contain full data without spaces then whole 104 lenth would be full. If all length fields data without spaces + 4 pipes(|) is less than 104 then remaining positions after last field(EMP-SALARY) can be filled with spaces.
that means you want a fixed length output.....................................................
have a look at smart DFSORT tricks document. Refer to "deconstrcut and reconstruct CSV records" section. it is a very good starting point for your requirement.
You are making things hard for yourself by not doing much to help yourself. Also search this forum, you'll find lots of SQZ and PARSE and JUSTIFY and stuff.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Ashutosh,
Here's an example of the type of thing you could use for the returning file. You've got several fields to do this for, and your fields are longer than my test field of 10 bytes (which needs 11 tests). You'll also have the problem of having to include the HIT=NEXT for the subsequent fields.
What is there that can actually be changed before the file comes back to you? As in which of the fields? One, all, how many? Unless they were all potentially subject to change, I'd prefer a match (with JOINKEYS, for instance) for what is coming back. Lets you do a bit of validation, always good when getting data from "someone else".
I'd also consider having some code to validate the lengths you do have for the fields going out, to check against the PARSEd fields. Not to check that the PARSE is working, but as an opportunity to check that the binary fields are actually correct.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
I've been playing around with the idea of checking the two field lengths from the record against the output.
This is fairly brutal. I've hacked Frank's code, to make it easier to test since TS didn't actually ask for it anyway. The important part is the inclusion of the field lengths (41,2,63,2) and the FTOV,VLTRIM=C' '
The second step then reads in the variable-length-record file, calculates what the record-length should have been if the field-lengths were correct (from the two field-lengths, the length of the field lengths, the number of delimiters (one in this case) and the RDW). Compares calculated to actual length and lists any anomolies.
I'd do this check as a matter of course. The length of those fields is being calculated again for the output record, so it should be verified against the existing field-length data.