Page 1 of 1

Join parts of two records from same file

Posted: Thu Apr 27, 2023 3:47 am
by Mickes
Hi,

I have a file (FB LRECL=20) that contains following four records:

File
20230417ABCD20230420
20230418ABCD20230421
20230419ABCD20230424
20230420ABCD20230425

What I want to accomplish is:
-Take first eight position from record 1 and combine it with character ',' and eight last position from record 2.
-Take first eight position from record 2 and combine it with character ',' and eight last position from record 3.
-Take first eight position from record 3 and combine it with character ',' and eight last position from record 4.
-Take first eight position from record 4 and combine it with character ',' and eight last position from record 5 (but there are only four records so put eight spaces instead).

The output should be a file (FB LRECL=17) containing:
20230417,20230421
20230418,20230424
20230419,20230425
20230420,

Thanks in advance,

Mikael

Re: Join parts of two records from same file

Posted: Thu Apr 27, 2023 12:23 pm
by sergeyken
Based on your post, one can think that you are the manager who assigns some tasks to the forum members?

I suspect this task has been assigned to yourself by your manager, but you decided to do nothing but hire free slaves from the forum, isn’t it?

Re: Join parts of two records from same file

Posted: Thu Apr 27, 2023 12:53 pm
by sergeyken
Hint:
- Create two copies of input, with line sequence numbers starting from 1 in one copy, and starting from 2 in another one,
- Join two copies by their sequence numbers,
- Combine the required fields from joined records.
That’s it.

Try TO DO SOMETHING YOURSELF, before assigning your task to others.
This is the rule for this forum.

Re: Join parts of two records from same file

Posted: Sat Apr 29, 2023 1:32 pm
by sergeyken
What have you tried so far??!!