i tried removing EDIT class but it did not work for me:(. also i just dont want to hard code DIV,+5...i want to populate it dynamically..since that value can change for the next key.
say for example
Code:
00010 050009700 008777700 +50 +222222222 +111111111 N 00002.00 I 00008.00
00010 050009700 008777800 +100 +222222222 +111111111 N 00003.00 I 00008.00
then i should recalulate it as
50+(100*3)/2=50+150=200
so my output will be
Code:
00010 050009700 008777700 +200 +222222222 +111111111 N 00002.00 I 00008.00
00010 050009700 008777800 +150 +222222222 +111111111 N 00003.00 I 00008.00
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
When attempting the Code tags, try the Preview button, it allows you to see what the Post looks like before you Submit it, so you can make changes if necessary.
From you earlier record-layout, it seems that STOCK is 24 for a length of 5, PD, not 4.
I'm not going to go through checking everything for you. You need to do that. I've hacked about your Cobol layout into SYMNAMES and produced the SYMNOUT from that.
Code:
------- ORIGINAL STATEMENTS FROM SYMNAMES -------
STORE,1,5,CH
PRODA,*,9,CH
PRODB,*,9,CH
STOCK,*,5,PD
QTY1,*,5,PD
QTY2,*,5,PD
IND,*,1,CH
SIZE,*,7,ZD
WEIGHT,*,1,CH
WGT,*,7,ZD
Your unreadable posts have been edited to use the code tags!
we moderators would appreciate if You started doing so Yourself
it' s a nuisance to have to waste time editing the posts of inconsiderate posters
but it' something that must be done to show respect and consideration
for the people spending time to help You !
use the preview button to check that Your posts look the way they should!
What should be the expected output for input records like below? This is where you have multiple PRODB records under PRODA but with the same values(00006.00) . Is it even possible?
Code:
00010 050009698 008774500 +100 +222222222 +111111111 N 00006.00 I 00008.00
00010 050009698 008774500 +100 +222222222 +111111111 N 00006.00 I 00008.00
00010 050009698 008774500 +100 +222222222 +111111111 N 00006.00 I 00008.00
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
useit wrote:
hi,
i have requirement which i want to achieve it through dfsort.
WHEN PRODA has multiple PRODB in STORE (when ALL PRODB has same size ):
then calculate the stock as 100+100+100=300
WHEN PRODA has multiple PRODB in STORE (when ALL PRODB has different size ):
then recalculate stock=100+(200*00006.10)/00005.00+(300*000007.20)/00005.00+(400*00008.00)/00005.00
=100+240+420+640=1400
useit,
You truly live up to your nickname USEit. I always wonder as to why people post imaginary requirements when they have trouble adapting the proposed solution to the real requirements. Are you under the assumption that we cannot comprehend the requirement as you do? You already have a topic about rounding and summing up the values and you cannot adopt that solution to the actual requirement here because there are many other factors to consider. As Bill pointed out, PD field you used in calculation is 5 bytes and you are calculating using just 4 bytes.
useit wrote:
i ran the below jcl . but it failed with rc=6.
RC=6? DFSORT does not issue an return code of 6. well I guess you are hungry and ate the 10 or you simply rounded it ? How hard is to post the complete sysout? I guess the mods did a good job adding the code tags to your post.
Anyway despite all the above the requirement isn't clear.
200*00006.10)/00005.00 = 244 but you had 240. So are you rounding the size field (value 6.10) to 6 and performing the math or you taking the entire 200*00006.10)/00005.00 = 244 and then round it to 240?
Which value are you rounding? And how is the rounding done? if it is size then any value greater than 49 in the decimal field will be rounded to next integer . ie 6.50, 6.99 becomes 7 and 6.01, 6.49 becomes 6.
Or if you are rounding after calculating the entire value , then how do you plan to round?
when i give 40,7,ZD Calculated value was wrong.when i give 40,5,ZD VALUE is populated correctly. what should be the lcorrect length of
FOR PIC 9(5)V99??
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
useit wrote:
Hi,
when i give 40,7,ZD Calculated value was wrong.when i give 40,5,ZD VALUE is populated correctly. what should be the lcorrect length of
FOR PIC 9(5)V99??
The correct length of 9(5)V99 is seven bytes. Note there is no way to define a decimal decimal place, 40,7,ZD could be 9(5)99 or 9(7) or V9(7) or anything which is seven digits with or without a decimal place. So you have to deal with any decimal places in your calculation. Is that what went "wrong"?
This is where you identify the first record which makes up your group of records.
If that record contains the "divisor" that you want to use "dynamically", extend the PUSH so that it includes, at a location you are not already using, a copy of the divisor which can be used for all the records. Remember you have decimal places in that as well, it seems.
sorry i did not get:( . my first record will contain a "divisor" at 40,7 position. am not aware how to extend the push command.could you please help me in this regard
The final IFTHEN is doing your "rounding up". For any number which is not exactly divisible by +6, one will be added to the result.
The MOD is used to work out the "exactly divisible", since if exactly divisble 14,2,ZD will be zero.
I don't know how it is "working" but not correct, but there we go.
You have no equivalent final IFTHEN, so you are just getting the straight output from DFSORT's DIV. Without the IFTHEN you don't need the MOD, but you won't get the "rounding up", you'll get the "rounding" from DIV.
You haven't used MOD instead of DIV, you've used both. As it stands, nothing is using the result of the MOD.