exchange value



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

exchange value

Postby pulcinella » Sun May 25, 2014 4:09 pm

Hi

First of all, excuse me if I do not explain correctly what I want to do, if not public in the correct forum or if someone has posted this problem.

I have a file. This file has a header line, multiple lines of detail and a final line. The header line starting with "01" and detail lines with "02" the final line by "03". In detail lines I have various amounts (several amounts by line detail) separated by semicolons. In the header line for the amount I must multiply each of the detail lines (= exchange value). The result should leave it in the same line of detail.
The quantity (amount) of the header has 3 decimal (3 integers and 3 decimals),. The amount of detail lines are packed decimal with 2 decimal [first import is 4,8,pd, second import is 13,8,pd... ). The result is that I get an amount rounded to two decimal places (same structure as the amount origin: 8 pd)
The final line should not be treated
In short, how I can multiply lines detail the amount of the header line, leaving the amount in the corresponding en detail, respecting the origin of the amount format (2 decimal integer 13 packed format) Can you explain how I can make easily? Thank you very much

Input (FB=30)
Output (FB=58)

Attach example
You do not have the required permissions to view the files attached to this post.
pulcinella
 
Posts: 114
Joined: Mon Dec 10, 2007 10:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: exchange value

Postby NicC » Mon May 26, 2014 12:54 am

After so many years in the forum you should know by now that posting attachments is not a good idea. Psot your sample input and expected out in the body of your text along with the control cards that you have tried so far - all within code tags to maintain spacing.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: exchange value

Postby pulcinella » Tue May 27, 2014 9:44 pm

Excuse me Nic,

I see the forum now. Excuse me for the attachment. It's a long time that I don't conect it and I had forgotten.

The input file (FB=30) is this:

01;  0,450;USD;                  --> header line
02;1.152,23;   55,70;   80,37;   --> detail line
02;1.265,45;   55,60;   80,00;   --> detail line
02;1.143,78;   52,10;   80,00;   --> detail line
02;1.056,23;   58,04;   80,00;   --> detail line
02;1.678,21;   55,50;   80,14;   --> detail line
02;1.535,28;   57,00;   80,00;   --> detail line
02;1.826,74;   56,00;   80,16;   --> detail line
02;  355,28;   28,80;   30,00;   --> detail line
02;1.120,00;   58,80;   80,00;   --> detail line
02;   55,13;    8,00;   15,00;   --> detail line
02;  261,45;   28,10;   30,17;   --> detail line
02;  257,26;   29,13;   30,00;   --> detail line
02;   53,12;    8,00;   15,00;   --> detail line
02;  258,54;   29,00;   30,00;   --> detail line
02;1.532,15;   53,10;   80,00;   --> detail line
02;    0,00;    0,20;    0,00;   --> detail line
03;   60;


I want to get this file (fb=58)

01;  0,450;USD;
02;1.152,23;   55,70;   80,37;   518,50;   25,07;   36,17;
02;1.265,45;   55,60;   80,00;   569,45;   25,02;   36,00;
02;1.143,78;   52,10;   80,00;   514,70;   23,45;   36,00;
02;1.056,23;   58,04;   80,00;   475,30;   26,12;   36,00;
02;1.678,21;   55,50;   80,14;   755,19;   24,98;   36,00;
02;1.535,28;   57,00;   80,00;   690,88;   25,65;   36,00;
02;1.826,74;   56,00;   80,16;   822,03;   25,20;   36,07;
02;  355,28;   28,80;   30,00;   159,88;   12,96;   13,50;
02;1.120,00;   58,80;   80,00;   504,00;   26,46;   36,00;
02;   55,13;    8,00;   15,00;    24,81;    3,60;    6,75;
02;  261,45;   28,10;   30,17;   117,65;   12,65;   13,58;
02;  257,26;   29,13;   30,00;   115,77;   13,11;   13,50;
02;   53,12;    8,24;   15,00;    23,90;    3,71;    6,75;
02;  258,54;   29,57;   30,00;   116,34;   13,31;   13,50;
02;1.532,15;   53,10;   80,00;   689,47;   23,90;   36,00;
02;    0,00;    0,20;    0,00;     0,04;    0,09;    0,04;
03;   60;


Code'd
pulcinella
 
Posts: 114
Joined: Mon Dec 10, 2007 10:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: exchange value

Postby enrico-sorichetti » Wed May 28, 2014 11:59 am

very good mood on

here is a snippet
 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  3 Line(s) not Displayed
 000004 //S1      EXEC PGM=SORT
 000005 //SYSPRINT  DD SYSOUT=*
 000006 //SYSOUT    DD SYSOUT=*
 000007 //SORTIN    DD *
 000008 01;  0,450;USD;DOLLARS;
 000009 02;1.152,23;   55,70;   80,37;
 000010 02;1.265,45;   55,60;   80,00;
 000011 02;1.143,78;   52,10;   80,00;
 000012 02;1.056,23;   58,04;   80,00;
 000013 02;1.678,21;   55,50;   80,14;
 000014 02;1.535,28;   57,00;   80,00;
 000015 02;1.826,74;   56,00;   80,16;
 000016 02;  355,28;   28,80;   30,00;
 000017 02;1.120,00;   58,80;   80,00;
 000018 02;   55,13;    8,00;   15,00;
 000019 02;  261,45;   28,10;   30,17;
 000020 02;  257,26;   29,13;   30,00;
 000021 02;   53,12;    8,00;   15,00;
 000022 02;  258,54;   29,00;   30,00;
 000023 02;1.532,15;   53,10;   80,00;
 000024 02;    0,00;    0,20;    0,00;
 000025 03;   60;
 000026 01;  0,123;KLD;DARSEKS;
 000027 02;1.152,23;   55,70;   80,37;
 000028 02;1.265,45;   55,60;   80,00;
 000029 02;1.143,78;   52,10;   80,00;
 000030 02;1.056,23;   58,04;   80,00;
 000031 02;1.678,21;   55,50;   80,14;
 000032 02;1.535,28;   57,00;   80,00;
 000033 02;1.826,74;   56,00;   80,16;
 000034 02;  355,28;   28,80;   30,00;
 000035 02;1.120,00;   58,80;   80,00;
 000036 02;   55,13;    8,00;   15,00;
 000037 02;  261,45;   28,10;   30,17;
 000038 02;  257,26;   29,13;   30,00;
 000039 02;   53,12;    8,00;   15,00;
 000040 02;  258,54;   29,00;   30,00;
 000041 02;1.532,15;   53,10;   80,00;
 000042 02;    0,00;    0,20;    0,00;
 000043 03;   60;
 000044 //SORTOUT   DD SYSOUT=*
 000045 //SYSIN     DD *
 000046   OPTION COPY
 000047   INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'01'),
 000048                  PUSH=(61:04,07)),
 000049          IFTHEN=(WHEN=(01,02,CH,EQ,C'02'),
 000050                  OVERLAY=(61:61,07,UFF,M11,LENGTH=8,
 000051                           71:04,08,UFF,M11,LENGTH=8,
 000052                           81:13,08,UFF,M11,LENGTH=8,
 000053                           91:22,08,UFF,M11,LENGTH=8,
 000054    31:((61,08,ZD,MUL,71,08,ZD),ADD,+500),DIV,+1000,EDIT=(I.IIT,TT),
 000055       C';',
 000056       ((61,08,ZD,MUL,81,08,ZD),ADD,+500),DIV,+1000,EDIT=(I.IIT,TT),
 000057       C';',
 000058       ((61,08,ZD,MUL,91,08,ZD),ADD,+500),DIV,+1000,EDIT=(I.IIT,TT),
 000059       C';'))
 000060    OUTREC BUILD=(1,60,80:X)
 ****** **************************** Bottom of Data ****************************



here is the result
********************************* TOP OF DATA **********************************
01;  0,450;USD;DOLLARS;
02;1.152,23;   55,70;   80,37;  518,50;   25,07;   36,17;
02;1.265,45;   55,60;   80,00;  569,45;   25,02;   36,00;
02;1.143,78;   52,10;   80,00;  514,70;   23,45;   36,00;
02;1.056,23;   58,04;   80,00;  475,30;   26,12;   36,00;
02;1.678,21;   55,50;   80,14;  755,19;   24,98;   36,06;
02;1.535,28;   57,00;   80,00;  690,88;   25,65;   36,00;
02;1.826,74;   56,00;   80,16;  822,03;   25,20;   36,07;
02;  355,28;   28,80;   30,00;  159,88;   12,96;   13,50;
02;1.120,00;   58,80;   80,00;  504,00;   26,46;   36,00;
02;   55,13;    8,00;   15,00;   24,81;    3,60;    6,75;
02;  261,45;   28,10;   30,17;  117,65;   12,65;   13,58;
02;  257,26;   29,13;   30,00;  115,77;   13,11;   13,50;
02;   53,12;    8,00;   15,00;   23,90;    3,60;    6,75;
02;  258,54;   29,00;   30,00;  116,34;   13,05;   13,50;
02;1.532,15;   53,10;   80,00;  689,47;   23,90;   36,00;
02;    0,00;    0,20;    0,00;    0,00;    0,09;    0,00;
03;   60;
01;  0,123;KLD;DARSEKS;
02;1.152,23;   55,70;   80,37;  141,72;    6,85;    9,89;
02;1.265,45;   55,60;   80,00;  155,65;    6,84;    9,84;
02;1.143,78;   52,10;   80,00;  140,68;    6,41;    9,84;
02;1.056,23;   58,04;   80,00;  129,92;    7,14;    9,84;
02;1.678,21;   55,50;   80,14;  206,42;    6,83;    9,86;
02;1.535,28;   57,00;   80,00;  188,84;    7,01;    9,84;
02;1.826,74;   56,00;   80,16;  224,69;    6,89;    9,86;
02;  355,28;   28,80;   30,00;   43,70;    3,54;    3,69;
02;1.120,00;   58,80;   80,00;  137,76;    7,23;    9,84;
02;   55,13;    8,00;   15,00;    6,78;    0,98;    1,85;
02;  261,45;   28,10;   30,17;   32,16;    3,46;    3,71;
02;  257,26;   29,13;   30,00;   31,64;    3,58;    3,69;
02;   53,12;    8,00;   15,00;    6,53;    0,98;    1,85;
02;  258,54;   29,00;   30,00;   31,80;    3,57;    3,69;
02;1.532,15;   53,10;   80,00;  188,45;    6,53;    9,84;
02;    0,00;    0,20;    0,00;    0,00;    0,02;    0,00;
03;   60;
******************************** BOTTOM OF DATA ********************************


some starting values of Your results example are different from those in the input
the data part of the first column of the computed values is 9 bytes instead of 8
some computations are just plain wrong ... 0.20 * 0.450 ==> 0.09 NOT 0.04

( probably because You did everything by hand )

PS ...
not just good mood, but TERRIFIC GOOD MOOD :ugeek:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: exchange value

Postby Aki88 » Wed May 28, 2014 12:30 pm

Enrico: 'Terrific mood'; the sun is shining, reminds me of Wordsworth ;) :mrgreen: :

The waves beside them danced, but they
Out-did the sparkling waves in glee:
A Poet could not but be gay,
In such a jocund company
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: exchange value

Postby enrico-sorichetti » Wed May 28, 2014 4:17 pm

follow on ...

The amount of detail lines are packed decimal with 2 decimal [first import is 4,8,pd, second import is 13,8,pd... ). The result is that I get an amount rounded to two decimal places (same structure as the amount origin: 8 pd)
The final line should not be treated


You talk about packed decimal but You show EDITED/DISPLAY/PRINTABLE data

...
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: exchange value

Postby pulcinella » Wed May 28, 2014 9:39 pm

Thanks a lot of. I probe it and tell you. I did not know how to explain it. It's not easy for me

Well suppose!!! I really worked with packed decimal but I show edited/display data for better understanding. And yes, I used my hand for the operations, excuse me.
pulcinella
 
Posts: 114
Joined: Mon Dec 10, 2007 10:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: exchange value

Postby dick scherrer » Wed May 28, 2014 11:38 pm

Hello,

When all one has is one's hand, that is what is used.

No excuse needed :)

I did not know how to explain it. It's not easy for meI

We will try to help.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: exchange value

Postby enrico-sorichetti » Thu May 29, 2014 12:14 am

this snippet works for a layout like


pos len format
01  2   CHAR    ( Record type 01-02-03)
03  8   PD
11  8   PD
...
... and so on
...

****** ***************************** Top of Data ******************************
- - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 15 Line(s) not Displayed
000016 //SYSIN     DD *
000017   OPTION COPY
000018   INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'01'),
000019                  PUSH=(71:3,8)),
000020          IFTHEN=(WHEN=(01,2,CH,EQ,C'02'),
000021                  OVERLAY=(01:01,2,
000022    27:((71,8,PD,MUL,03,08,PD),ADD,+500),DIV,+1000,TO=PD,LENGTH=8,
000023       ((71,8,PD,MUL,11,08,PD),ADD,+500),DIV,+1000,TO=PD,LENGTH=8,
000024       ((71,8,PD,MUL,19,08,PD),ADD,+500),DIV,+1000,TO=PD,LENGTH=8))
000025    OUTREC BUILD=(1,50,80:X)
****** **************************** Bottom of Data ****************************


easy to take into account different lengths and the separating ";"
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to DFSORT/ICETOOL/ICEGENER