2013 Apr 18 2:14 AM
SELECT
KONV~KNUMV
konv~kposn
konv~kschl
konv~kbetr as kbetr2
into CORRESPONDING FIELDS OF TABLE it_display3 from konv
for ALL ENTRIES IN it_display where
konv~knumv = it_display-knumv AND
konv~kschl = 'ZCAS'.
LOOP AT it_display.
READ TABLE it_display3 WITH KEY knumv = it_display-knumv . ( You also need to match the KPOSN )
IF sy-subrc = 0.
it_display-kbetr2 = ( it_display3-kbetr2 / 10 ).
MODIFY it_display.
ENDIF.
ENDLOOP.
I have created another select statement for pr00 as in the above manner.
i wanted to do konv~kschl = PR00 - konv~kschl=ZCAS (PR00 - ZCAS). how to write . I wanted knumv in the selection parameter for this . data should populate based on the selection parameter
2013 Apr 18 5:57 AM
Hi,
You can use the following statement.
SELECT
KONV~KNUMV
konv~kposn
konv~kschl
konv~kbetr as kbetr2
into CORRESPONDING FIELDS OF TABLE it_display3 from konv
for ALL ENTRIES IN it_display where
konv~knumv = it_display-knumv AND
konv~kschl IN ('ZCAS','PR00').
lets take 2 variable V_ZCAS and Z_PR00
in order for calculation you can do the following.
loop at it_display.
read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'ZCAS'.
if sy-subrc = 0.
add the value of 'ZCAS'
V_ZCAS = it_display3-kbetr / 10 .
endif.
clear it_display3. ( Should clear the work area )
read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'PR00'.
if sy-subrc = 0.
add the value of 'PR00'
V_PR00 = it_display3-kbetr / 10 .
endif.
clear it_display3. ( Should clear the work area )
total = Z_PR00 - V_ZCAS.
endloop.
Regards,
Rahul Singh
Now you can close this thread .....
2013 Apr 18 5:15 AM
Hi,
I am combining the select for both ZCAS and PR00 conditions in the below query.
SELECT
KONV~KNUMV
konv~kposn
konv~kschl
konv~kbetr as kbetr2
into CORRESPONDING FIELDS OF TABLE it_display3 from konv
for ALL ENTRIES IN it_display where
konv~knumv = it_display-knumv AND
( konv~kschl = 'ZCAS'
or KONV~kschl = 'PR00').
sort it_display3 by kschl.
it_display4[] = it_display3[].
delete it_display3 where kschl NE 'ZCAS'. " This internal table will have only ZCAS
delete it_display4 where kschl NE 'PR00'. " This internal table will have only PR00
LOOP AT it_display.
* ZCAS value
READ TABLE it_display3 WITH KEY knumv = it_display-knumv . ( You also need to match the KPOSN )
IF sy-subrc = 0.
lv_kbetr1 = ( it_display3-kbetr2 / 10 ).
ENDIF.
*PR00 value
READ TABLE it_display4 WITH KEY knumv = it_display-knumv . ( You also need to match the KPOSN )
IF sy-subrc = 0.
lv_kbetr2 = ( it_display4-kbetr2 / 10 ).
ENDIF.
lv_kbetr3 = lv_kbetr2 - lv_kbetr1. " PR00 minus ZCAS
*lv_kbetr3 will have the value for PR00 minus ZCAS
ENDLOOP.
Cheers
~Niranjan
2013 Apr 18 5:57 AM
Hi,
You can use the following statement.
SELECT
KONV~KNUMV
konv~kposn
konv~kschl
konv~kbetr as kbetr2
into CORRESPONDING FIELDS OF TABLE it_display3 from konv
for ALL ENTRIES IN it_display where
konv~knumv = it_display-knumv AND
konv~kschl IN ('ZCAS','PR00').
lets take 2 variable V_ZCAS and Z_PR00
in order for calculation you can do the following.
loop at it_display.
read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'ZCAS'.
if sy-subrc = 0.
add the value of 'ZCAS'
V_ZCAS = it_display3-kbetr / 10 .
endif.
clear it_display3. ( Should clear the work area )
read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'PR00'.
if sy-subrc = 0.
add the value of 'PR00'
V_PR00 = it_display3-kbetr / 10 .
endif.
clear it_display3. ( Should clear the work area )
total = Z_PR00 - V_ZCAS.
endloop.
Regards,
Rahul Singh
Now you can close this thread .....
2016 Feb 15 9:32 PM
2013 Apr 18 6:32 AM
Hi,
You can try this statement:
SELECT
KONV~KNUMV
konv~kposn
konv~kschl
konv~kbetr as kbetr2
into CORRESPONDING FIELDS OF TABLE it_display3 from konv
for ALL ENTRIES IN it_display where
konv~knumv = it_display-knumv AND
konv~kschl IN ('ZCAS','PR00').
LOOP AT it_display.
READ TABLE it_display3 WITH KEY knumv = it_display-knumv .
IF sy-subrc = 0.
* ZCAS value
if t_display3-kschl = 'ZCAS'.
lv_kbetr = ( it_display3-kbetr2 / 10 ).
ELSE.
*PR00 value
lv_kbetr = ( it_display3-kbetr2 / 10 ).
ENDIF.
if lv_kbetr is not initial.
it_display-kbetr2 = lv_kbetr.
MODIFY it_display.
endif.
ENDIF.
ENDLOOP.
2013 Apr 18 7:15 AM
2013 Apr 18 7:19 AM