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 about the flow...

Former Member
0 Likes
376

HI all

i have the following piece of code, please explain me how the logic works..

LOOP AT T_BAL INTO V_H_BALANCES.

MOVE V_H_BALANCES TO V_TEMP_BALANCES.

AT END OF MATNR.

SUM.

MOVE V_H_BALANCES-KSPEM TO V_TEMP_BALANCES-KSPEM.

MOVE V_H_BALANCES-SPEME TO V_TEMP_BALANCES-SPEME.

MOVE V_H_BALANCES-BOTH_QTY TO V_TEMP_BALANCES-BOTH_QTY.

APPEND V_TEMP_BALANCES TO T_TEMP_BALANCES.

ENDAT.

CLEAR V_H_BALANCES.

ENDLOOP.

and my T_BAL internal table contains these feilds.

TYPES: BEGIN OF TY_BAL,

WERKS TYPE MARD-WERKS,

MATNR TYPE MARD-MATNR,

LGORT TYPE MARD-LGORT,

SPEME TYPE MARD-SPEME, " Owned Blocked

KSPEM TYPE MARD-KSPEM, " Consigned Blocked

MEINH TYPE MARM-MEINH,

MAKTX TYPE MAKT-MAKTX,

MATKL TYPE MARA-MATKL,

MVGR4 TYPE MVKE-MVGR4,

PRAT2 TYPE MVKE-PRAT2,

COST TYPE MBEW-VMSAL,

STPRS TYPE MBEW-VMSAL,

PEINH TYPE MBEW-PEINH,

PH_MATNR TYPE MVKE-MATNR,

MENGE(16) TYPE P DECIMALS 0, "STPO-MENGE,

TOT_SPEME(16) TYPE P DECIMALS 0, "MARD-SPEME,

TOT_KSPEM(16) TYPE P DECIMALS 0, "MARD-KSPEM,

BOTH_QTY(16) TYPE P DECIMALS 0, "MARD-SPEME, "SPEME & KSPEM

END OF TY_BAL.

thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
358

Hi,

In this piece of code, the developer is trying to do the following:

- Loop at every record of the internal table(T_BAL) and get it into a work area (V_H_BALANCES ).

- Mode the field contents of the work area(V_H_BALANCES ) into another work area (V_TEMP_BALANCES).

- Then for every change of MATNR field he is adding all the numeric fields.

- Then transfering all the fields ( i.e. added fields ) in to another work area (V_TEMP_BALANCES) .

- Adding this new set of record( added values ) from one internal table ( V_TEMP_BALANCES)to the other internal table (T_TEMP_BALANCES).

The result would be somthing as :

Old Internal table(T_BAL):

werks matnr lgort

0001 screw1 20

0001 screw1 30

0001 screw2 10

0001 screw2 20

Then after you run this piece of code then, the contents of the new interna table (T_TEMP_BALANCES) would be :

werks matnr lgort

0001 screw1 50

0001 screw2 30

Hope that makes the picture a lil clear.

Award points if founf useful.

Best Regards.

Ashish Singhal.

Hi,

In this piece of code, the developer is trying to do the following:

- Loop at every record of the internal table(T_BAL) and get it into a work area (V_H_BALANCES ).

- Mode the field contents of the work area(V_H_BALANCES ) into another work area (V_TEMP_BALANCES).

- Then for every change of MATNR field he is adding all the numeric fields.

- Then transfering all the fields ( i.e. added fields ) in to another work area (V_TEMP_BALANCES) .

- Adding this new set of record( added values ) from one internal table ( V_TEMP_BALANCES)to the other internal table (T_TEMP_BALANCES).

The result would be somthing as :

Old Internal table(T_BAL):

werks matnr lgort

0001 screw1 20

0001 screw1 30

0001 screw2 10

0001 screw2 20

Then after you run this piece of code then, the contents of the new interna table (T_TEMP_BALANCES) would be :

werks matnr lgort

0001 screw1 50

0001 screw2 30

Hope that makes the picture a lil clear.

Award points if founf useful.

Best Regards.

Ashish Singhal.

1 REPLY 1
Read only

Former Member
0 Likes
359

Hi,

In this piece of code, the developer is trying to do the following:

- Loop at every record of the internal table(T_BAL) and get it into a work area (V_H_BALANCES ).

- Mode the field contents of the work area(V_H_BALANCES ) into another work area (V_TEMP_BALANCES).

- Then for every change of MATNR field he is adding all the numeric fields.

- Then transfering all the fields ( i.e. added fields ) in to another work area (V_TEMP_BALANCES) .

- Adding this new set of record( added values ) from one internal table ( V_TEMP_BALANCES)to the other internal table (T_TEMP_BALANCES).

The result would be somthing as :

Old Internal table(T_BAL):

werks matnr lgort

0001 screw1 20

0001 screw1 30

0001 screw2 10

0001 screw2 20

Then after you run this piece of code then, the contents of the new interna table (T_TEMP_BALANCES) would be :

werks matnr lgort

0001 screw1 50

0001 screw2 30

Hope that makes the picture a lil clear.

Award points if founf useful.

Best Regards.

Ashish Singhal.