‎2006 Dec 18 12:35 PM
<b>Hi i have a got a problem like this in which i have to add the following fields to ED and after that i have to add that filed ED to ED1 and now i have followed the following code by which i'm able to get ED value when JEC1 is not declared but when the JEC1 is declared as below then i'm not able to get the value of ED1 can u suggest me any solution plzzzzz</b>
If KONH-KSCHL=JMOP, then put this value and KONH-KNUMH in KONP-KNUMH, and obtain KONP-KBETR (this is for ED)
Calculate ED as KONP-KBETR/10 * EKPO-NETWR
If KONH-KSCHL=JEC1, then put this value and KONH-KNUMH in KONP-KNUMH, and obtain KONP-KBETR (this is for ECess)
Calculate ED1 as KONP-KBETR/10 * ED
<b>for this conditions i had followed the following steps</b>
LOOP AT JTAB.
concatenate JTAB-werks JTAB-lifnr JTAB-matnr
into val.
SELECT SINGLE KONHKNUMH KONHKSCHL FROM KONH INTO
CORRESPONDING FIELDS OF
KTAB WHERE KONH~VAKEY = VAL .
IF KTAB-KSCHL = 'JMOP' .
.
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONPKNUMH = KTAB-KNUMH AND KONPKSCHL = KTAB-KSCHL
.
ED = KBTAB-KBETR / 10 * JTAB-NETWR .
ED1 = KBTAB-KBETR / 10 * ED.
ENDIF.
IF KTAB-KSCHL = 'JEC1' .
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONPKNUMH = KTAB-KNUMH AND KONPKSCHL = KTAB-KSCHL
. ED1 = KBTAB-KBETR / 10 * ED.
ENDIF.
‎2006 Dec 18 1:22 PM
As per your code you would get the value of ED1 as zero since the value of ED has not been calculated. I think try and change the code as below and see if it fits your requirement.
LOOP AT JTAB.
concatenate JTAB-werks JTAB-lifnr JTAB-matnr
into val.
refresh KTAB.
SELECT KONHKNUMH KONHKSCHL FROM KONH INTO
CORRESPONDING FIELDS OF TABLE
KTAB WHERE KONH~VAKEY = VAL .
sort ktab by kschl descending.
Loop at KTAB.
IF KTAB-KSCHL = 'JMOP' .
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONPKNUMH = KTAB-KNUMH AND KONPKSCHL = KTAB-KSCHL.
ED = KBTAB-KBETR / 10 * JTAB-NETWR .
ENDIF.
IF KTAB-KSCHL = 'JEC1' .
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONPKNUMH = KTAB-KNUMH AND KONPKSCHL = KTAB-KSCHL.
ED1 = KBTAB-KBETR / 10 * ED.
ENDIF.
Endloop.
‎2006 Dec 18 12:42 PM
HI,
TRY USING CASE AND ENDCASE .
eg.
case KTAB-KSCHL.
when 'JMOP' .
.
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONP~KNUMH = KTAB-KNUMH AND KONP~KSCHL = KTAB-KSCHL
.
ED = KBTAB-KBETR / 10 * JTAB-NETWR .
ED1 = KBTAB-KBETR / 10 * ED.
when 'JEC1' .
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONP~KNUMH = KTAB-KNUMH AND KONP~KSCHL = KTAB-KSCHL
. ED1 = KBTAB-KBETR / 10 * ED.
when ''.
*for null value check.
endcase.
‎2006 Dec 18 12:49 PM
Hi Mr. Vickram
I have tried by using your code even though it was only calculating for ED but not for ED1
‎2006 Dec 18 12:53 PM
Hi pavan,
How would it calculate ED1 when the line is commented out?
ED1 = KBTAB-KBETR / 10 * ED.
‎2006 Dec 18 1:00 PM
Hi Mr . Ramana
I think u have seen the upper statement in which i had declared for JMOP in which i had tried to add ED and ED1 at the same time but even though it was not working so i had commented that
‎2006 Dec 18 1:22 PM
As per your code you would get the value of ED1 as zero since the value of ED has not been calculated. I think try and change the code as below and see if it fits your requirement.
LOOP AT JTAB.
concatenate JTAB-werks JTAB-lifnr JTAB-matnr
into val.
refresh KTAB.
SELECT KONHKNUMH KONHKSCHL FROM KONH INTO
CORRESPONDING FIELDS OF TABLE
KTAB WHERE KONH~VAKEY = VAL .
sort ktab by kschl descending.
Loop at KTAB.
IF KTAB-KSCHL = 'JMOP' .
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONPKNUMH = KTAB-KNUMH AND KONPKSCHL = KTAB-KSCHL.
ED = KBTAB-KBETR / 10 * JTAB-NETWR .
ENDIF.
IF KTAB-KSCHL = 'JEC1' .
SELECT SINGLE KONP~KBETR FROM KONP INTO KBTAB WHERE
KONPKNUMH = KTAB-KNUMH AND KONPKSCHL = KTAB-KSCHL.
ED1 = KBTAB-KBETR / 10 * ED.
ENDIF.
Endloop.
‎2006 Dec 18 1:58 PM
One addition ot this what you can do is use the CHECK statement to find the value of KTAB-KSCHL. Here you can specify whether it is JMOP or JEC1. If it not there it will exit from the loop.