Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Doubt

Former Member
0 Likes
767

HI all.

I need to do the calculation for KBETR based on KSCHIL .all fields from KONV table.

Formula

If internal table it_ KONV-KSCHIL has YDIS

it_ KONV-KBETR = (KONV-KSCHIL) - (KONV-KSCHIL + KONV-KSCHIL + KONV-KSCHIL)

pls refer example internal table values.

ie) it_ KONV-KBETR = (2000 for YDIS) - (10 for YINP + 150 for YICP +40 for JMAN)

Result is KBETR = 1800.

I need to sum KBETR field if the field KSCHIL has value like YDIS.

Eg: KNUMV KSCHIL KBETR

6789999 YDIS 2000

6789999 YINP 10

6789999 YICP 150

6789999 JMAN 40

Pls give me logic.

<REMOVED BY MODERATOR>

Regards.

Jay

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:13 PM

6 REPLIES 6
Read only

Former Member
0 Likes
738

Loop at i_KONV.

if i_KONV-KSCHIL CA 'YDIS'.

v_sum = v_sum + i_KONV-KBETR.

else.

v_others = v_others + i_KONV-KBETR.

endif.

at end of KNUMV.

v_total = v_sum - v_others.

clear : v_total , v_sum , v_others.

endat.

endloop.

Read only

0 Likes
738

HI Srinivas.

take this example

Eg: KNUMV KSCHIL KBETR

6789999 YDIS 2000

6789999 YINP 10

6789999 YICP 150

6789999 JMAN 40

6789999 JXXX 40

Now i want sum only which has YINP,YICP and JMAN.

then i need to Subtract the YDIS value from above total.I dont want consider all records what are available in internal table. so i will not go to consider 5th record ie JXXX.

pls give me logic fot this.

<REMOVED BY MODERATOR>

Regards.

jay

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:14 PM

Read only

0 Likes
738

Loop at i_KONV.

if i_KONV-KSCHIL CA 'YDIS'.

v_sum = v_sum + i_KONV-KBETR.

elseif i_KONV-KSCHIL = 'YINP'

or i_KONV-KSCHIL = 'YICP'

or i_KONV-KSCHIL = 'JMAN'.

v_others = v_others + i_KONV-KBETR.

endif.

at end of KNUMV.

v_total = v_sum - v_others.

clear : v_total , v_sum , v_others.

endat.

endloop.

Read only

0 Likes
738

Hi,

Check this code.

Declare the variables appropriately.



Read table itab with key kschl = ydis binary search transporting knumv  kbetr.
if sy-subrc = 0 .
var_knumv = itab-knumv
var_ydis = itab-kbetr.
endif.

delete from itab where sy-index = sy-tabix.

Read table itab with key kschl = yinp binary search transporting kbetr.
if sy-subrc = 0 .
var_yinp = itab_kbetr.
endif.

delete from itab where sy-index = sy-tabix.

Read table itab with key kschl = yicp binary search transporting kbetr.
if sy-subrc = 0 .
var_yicp = itab_kbetr.
endif.

delete from itab where sy-index = sy-tabix.

Read table itab with key kschl = jman binary search transporting kbetr.
if sy-subrc = 0 .
var_jman = itab_kbetr.
endif.

delete from itab where sy-index = sy-tabix.

Now you will have the appropriate values, so do your calculations as reqd.

Incase you dont want to use the delete statement, copy the internal table to another internal table and do the process.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:14 PM

Read only

0 Likes
738

Hi Raj

iam using global structure in selct quary like

SELECT * FROM konv

WHERE konv~mandt = sy-mandt AND

knumv = vbrk-knumv AND

kposn = vbrp-posnr.

how can i manage? iam not using Internal table ,pls give me solution.

Regards.

Jay

Read only

0 Likes
738

Hi Srini.

iam using global structure ,how can replace iternal table.

pls guide me,

regards,

jay