2008 Apr 07 8:36 AM
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.
2008 Apr 07 8:47 AM
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.
2008 Apr 07 8:47 AM
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.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |