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

Logic required for a Internal table issue

Former Member
0 Likes
826

Hi Experts,

I have a small issue in the internal table logic. For the below data showing the structure of my internal table. Depends on data the internal table records will increase or decrease.

Currently my problem is i want to add Copyright Fee's (KSCHL= ZCFP) NETWR value and i want to display in one row.

For example the below data having 2 different material number, for 1st it should be 38 + 4.43 = 42.43. And the second material having 138 + 4.4 = 142.4.



VBELN	           ARKTX	                   MATNR	NETWR	KSCHL	GR_KZWI1
9014000000	PRINTER (G T644N P3 EMEA ENG4	20G2091	        891.3           291.76
9014000000	Copyright Fee		                        38      ZCFP    1291.76
9014000000	Tax Jur Code Level 1		                167.27  ZTR1    1291.76
9014000000	Ausgangssteuer		                        836.33  ZTXD    1291.76
9014000000	Copyright Fee		                          4.43  ZCFP   1291.76
9014000000	Tax Jur Code Level 1		                19.48   ZTR1    1291.76
	         Ausgangssteuer		                      97.41   ZTXD   91.76

9014000001	PRINTER (G T644N P3 EMEA ENG4	20G2091	        891.3           291.76
9014000001	Copyright Fee		                       138      ZCFP    1291.76
9014000001	Tax Jur Code Level 1		                167.27  ZTR1    1291.76
9014000001	Ausgangssteuer		                        836.33  ZTXD    1291.76
9014000001	Copyright Fee		                           4.4  ZCFP   1291.76
9014000001	Tax Jur Code Level 1		                19.48   ZTR1    1291.76
	        Ausgangssteuer		                       97.41   ZTXD   91.76


How i made a logic for this.??

Mohana

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
790

Hi

i want to display in one row

Can u calculate manually and highlight the result how it should be.

Hi Experts,

I have a small issue in the internal table logic. For the below data showing the structure of my internal table. Depends on data the internal table records will increase or decrease.

Currently my problem is i want to add Copyright Fee's (KSCHL= ZCFP) NETWR value and i want to display in one row.

For example the below data having 2 different material number, for 1st it should be 38 + 4.43 = 42.43. And the second material having 138 + 4.4 = 142.4.



VBELN	           ARKTX	                   MATNR	NETWR	KSCHL	GR_KZWI1
9014000000	PRINTER (G T644N P3 EMEA ENG4	20G2091	        891.3           291.76
9014000000	Copyright Fee		                        38      ZCFP    1291.76
9014000000	Tax Jur Code Level 1		                167.27  ZTR1    1291.76
9014000000	Ausgangssteuer		                        836.33  ZTXD    1291.76
9014000000	Copyright Fee		                          4.43  ZCFP   1291.76
9014000000	Tax Jur Code Level 1		                19.48   ZTR1    1291.76
	         Ausgangssteuer		                      97.41   ZTXD   91.76

9014000001	PRINTER (G T644N P3 EMEA ENG4	20G2091	        891.3           291.76
9014000001	Copyright Fee		                       138      ZCFP    1291.76
9014000001	Tax Jur Code Level 1		                167.27  ZTR1    1291.76
9014000001	Ausgangssteuer		                        836.33  ZTXD    1291.76
9014000001	Copyright Fee		                           4.4  ZCFP   1291.76
9014000001	Tax Jur Code Level 1		                19.48   ZTR1    1291.76
	        Ausgangssteuer		                       97.41   ZTXD   91.76


How i made a logic for this.??

Mohana

5 REPLIES 5
Read only

Former Member
0 Likes
790

Hi,

Make sure your internal table is in the below order of fields:

VBELN KSCHL MATNR NETWR ARKTX GR_KZWI1

Now after fetching the data, Loop at the internal table, for each record, do the below.

LOOP at Itab

V_SUM = V_SUM + itab-netwr

at end of MATNR

move the sum to another internal table

Endat.

Endloop.

Regards

Shiva

Read only

Former Member
0 Likes
790

Hi,

Make sure your internal table is in the below order of fields:

VBELN KSCHL MATNR NETWR ARKTX GR_KZWI1

Now after fetching the data, Loop at the internal table, for each record, do the below.

LOOP at Itab

V_SUM = V_SUM + itab-netwr

at end of MATNR

move the sum to another internal table

Endat.

Endloop.

Regards

Shiva

Read only

Former Member
0 Likes
790

Use collect instead of append to create the entries.

Read only

Former Member
0 Likes
790

hi,

Try this.

Assumptions

itab1 - actual data

itab2 - holds final data ( with added values )

wa1 - work area.

wa2 - holds copyright row with added values.

total - holds added values for a vbeln


total = 0.
flag = 0.
loop at itab1 into wa1.
  at new vbeln.
     if total ne 0.
         wa2-NETWR = total.
         append wa2 to itab2.
     endif.
     total = 0.
  endat. 

  if wa1-ARKTX ne 'Copyright Fee'.
    append wa1 into itab2.
  else.
    total = total + wa1-NETWR.
    wa2 = wa1.
  endif.
endloop.

Hope, this logic helps u.

Regards,

Bhavesh Solanki.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
791

Hi

i want to display in one row

Can u calculate manually and highlight the result how it should be.