PRODUCT PRODUCT QTY1 QTY2 QTY3 IND SIZE WEGHT UNIT
Z(9) (6-14) Z(9) (15-23) PS(9) (24-28) PS(9) (29-33) PS(9) (34-38) C(1) Z(5,2) (40-46) C(1) (47-47) Z(5,2) (48-54)
----------- ------------ ------------- ------------- ------------- ---- -------------- ------------ --------------
****************************** TOP OF DATA *********************************************** *********************************
050009698 008774500 +192 +9 +9 N 00003.00 I 00008.00
050009698 000011512 +10 +9 +1 N 00006.00 I 00002.13
050009698 008373548 +6 +9 +9 N 00009.00 I 00008.40
similarly i have to recalculate QTY2 field. if i do it in two seperate steps it is working fine. but when i tried to do it in single step. i am getting some huge numbers. getting wrong result.what could be the reaason for this? is there any syntax problem in the below code
Well, you have several problems with varying impacts.
You are ignoring decimal places, but doesn't cause the problem.
You have a "spare" HIT=NEXT not followed by WHEN=logicalexpression, but doesn't cause the problem.
You have no need to repeat the test, both calculations can be done under the same IFTHEN, but doesn't cause the problem...
You need to look at and understand exactly what your existing OVERLAY is doing and the field positionS(!) which ARE occupied. Then review the starting position for your "second" field. This is your actual problem.
When taking a solution given to you, it is a really good idea to thoroughly understand it before using it seriously. If you had done that, I don't thing any of the above would have been coded.
I have no idea as to why you have a MOD operation. Please don't use solutions from different topics and get confused. You say you want to divide with a constant of +3 but your control cards are using a field to divide. How about you come up with the actual requirement telling us the rules instead of correcting your logic?
in the above jcl i have considered only the integer part while dividing.i tried calculating even considering decimal part. it worked fine. but jcl will always round down.how to round up the value? do we need MOD functionality to round up?
The MOD you had previously was used as a way of knowing if you number was exactly divisible by the "pack size" or whatever it was. If not exactly divisible, then you'd "round up" to the nearest "pack size".
If you can set out exactly what it is you are trying to achieve, it will help.
If you are trying to use "variables" it is best not to only show examples with literal values.
Consult the manual and find out what MOD does. That should allow you to understand why it was suggested to you originally for the "rounding up". If you remove the code for the MOD, you won't get the "rounding up".
Note, this is not something specifically to do with MOD, it is logic you apply to the result of MOD to achieve your aim.
I am not even sure as to how you can say you got the desired results. You show the division by a constant of +3 or +300 as examples but your control cards are picking up a value division from the input file. The value 3 or 300 doesn't even exist in your input. I pointed out this earlier too and you just ignore it and continue with your own imaginary calculations.
You don't need to calculate the values on JNF1CNTL also as it serves no purpose. You only have 1 file and you want to update the values adding up the values for each key. If you use sum function you would end up with 1 record. So that is the reason as to why we use the same input file twice and JNF2CNTL will sum up the results into a single record and then you can use the join function to update the values on to the first record.
So understand the solutions before you implement them. Do not use code that you don't understand. Take a moment to understand the solution and use it. Refer the manuals and understand each keyword.
There are many ways to skin a cat. Since you want to round to next integer In simple math terms
(6*0000*9.80) = 58.8
58.8/3 = 19.6 ie (19 * 3 = 57 + remainder 1.8)
Now to make it 20 you can check if the remainder > 0 and add 1 to 19 making 20
or you can divide the remainder by remainder itself and add it to 19.
(58.8 /3 ) + mod(58.8/3) /mod(58.8/3) = 19+1 = 20
In case of evenly divisible values it would be 0. DFSORT puts 0/0 as 0
(10*6)/3 = 60/3 = 20 and remainder is 0
(60/3) + mod(60/3) / mod(60/3) = 20
Use this JCL which will give you the desired results. I calculated QTY1, QTY2, and also QTY3
You have, again, wasted time by continuing to show literal values when you want data values from your records.
You did this in your previous topic with similar "rounding" and you did it twice here despite Kolusu's question and my suggestion.
Please avoid doing this in the future, as people spend time on what you provide, since we are not mind-readers.
You have a solution. Run it as is until you understand exactly how everything is workin and what is different from your previous topic. You can "take it apart" to run small elements at a time to see the effects.
Read the manual specifically for the functions used. Use the functions and review their effects. Return to the manual to ensure that you are clear about how each function works.
This sort of method can help you get there on your own in countless different situations.
Of course, when you've got everything you should be able to make the changes yourself to use the data from the file. I'd suggest a SYMNAME or two to save typing of repeated values.