Skip to Content
0
Former Member
Jun 28, 2007 at 04:51 AM

Still not solved problem

22 Views

Hello Friends,

I am using 6 tables in my report.i want to display recores by AT NEW and Related stuff.

Can i use following code for query and internal tables ?

or Sujjest me Better code.

to use loop within loop is not good idea.

I want to disply Records

total Document type wise ->year wise -> Month wise -> Sales Order Number wise->Item Numberwise -> Production order numberwise

This is interactive report of 8-9 screens !!

Main problem is to make AT new with different loop !!

Sujjest me with code !!

Points will be rewarded soon !!

Regards,

Nimesh Master

  • TABLE DECLARATION ************************

TABLES : VBAK,AFPO,AUFM,MAKT,KNA1,VBAP.

  • INTERNAL TABLE DECLARATION *******************

DATA : BEGIN OF T1 OCCURS 0,

AUART TYPE VBAK-AUART,

NETWR TYPE VBAK-NETWR,

KUNNR TYPE VBAK-KUNNR,

VBELN TYPE VBAK-VBELN,

AUDAT TYPE VBAK-AUDAT,

END OF T1.

DATA : BEGIN OF T2 OCCURS 0,

NETWR TYPE VBAP-NETWR,

POSNR TYPE VBAP-POSNR,

END OF T2.

DATA : BEGIN OF T3 OCCURS 0,

AUFNR TYPE AFPO-AUFNR,

KDPOS TYPE AFPO-KDPOS,

KDAUF TYPE AFPO-KDAUF,

PSMNG TYPE AFPO-PSMNG,

WEMNG TYPE AFPO-WEMNG,

END OF T3.

DATA : BEGIN OF T4 OCCURS 0,

DMBTR TYPE AUFM-DMBTR,

MATNR TYPE AUFM-MATNR,

ELIKZ TYPE AUFM-ELIKZ,

END OF T4.

DATA : BEGIN OF T5 OCCURS 0,

NAME1 TYPE KNA1-NAME1,

END OF T5.

DATA : BEGIN OF T6 OCCURS 0,

MAKTX TYPE MAKT-MAKTX,

END OF T6.

FREE T1.

SELECT VBELN NETWR AUART AUDAT KUNNR FROM VBAK INTO CORRESPONDING FIELDS

OF TABLE T1 WHERE AUART IN AUART AND VBELN IN VBELN.

FREE T2.

SELECT NETWR POSNR FROM VBAP INTO CORRESPONDING FIELDS OF TABLE T2

FOR ALL ENTRIES IN T1 WHERE VBELN = T1-VBELN .

FREE T3.

SELECT AUFNR PSMNG WEMNG KDPOS FROM AFPO INTO CORRESPONDING FIELDS OF

TABLE T3 FOR ALL ENTRIES IN T1 WHERE KDAUF = T1-VBELN .

FREE T4.

SELECT DMBTR MATNR ELIKZ FROM AUFM INTO CORRESPONDING FIELDS OF

TABLE T4 FOR ALL ENTRIES IN T3 WHERE AUFNR = T3-AUFNR.

FREE T6.

SELECT MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF TABLE T6 WHERE

MATNR = T4-MATNR.

FREE T5.

SELECT NAME1 FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE T5 WHERE

KUNNR = T1-KUNNR.

LOOP AT T1.

AT NEW VBELN.

WRITE : / T1-VBELN .

ENDAT.

AT NEW AUFNR.

WRITE : / T1-AUFNR.

ENDAT.

AT END OF AUFNR.

SUM.

IF T1-PSMNG = T1-WEMNG.

T1-CLOSE_ORD1 = T1-CLOSE_ORD1 + T1-DMBTR.

ELSE.

T1-OPEN_ORD1 = T1-OPEN_ORD1 + T1-DMBTR.

ENDIF.

TOT_DMBTR_C = TOT_DMBTR_C + T1-CLOSE_ORD1.

TOT_DMBTR_O = TOT_DMBTR_O + T1-OPEN_ORD1 .

ENDAT.

AT END OF VBELN.

SUM.

P = TOT_DMBTR_C.

Q = TOT_DMBTR_O.

TMP_OC_SALES = NET_PRICE - P.

TMP_PER_SALES = ( TMP_OC_SALES * 100 ) / NET_PRICE .

TMP_TOT_MAT = P + Q.

TMP_PER_MAT = ( TMP_TOT_MAT * 100 ) / NET_PRICE.

TOT_NET_SALES_A = TOT_NET_SALES_A + NET_PRICE.

TOT_P_A = TOT_P_A + P.

TOT_Q_A = TOT_Q_A + Q.

ENDIF.

FORMAT COLOR 2 ON.

WRITE : 20 NET_PRICE,

50 P,

65 Q,

83 TMP_OC_SALES,

100 TMP_PER_SALES,'%',

120 TMP_TOT_MAT ,

139 TMP_PER_MAT,'%'.

FORMAT COLOR 2 OFF.

ENDAT.

ENDLOOP.

1. Tell me is it appropriate to take same number of INTERNAL TABLE as DDIC

TABLE ??

2. Wat should be the queries for them ?

3. How i use AT NEW with Different Loop for Internal tables ??