Application Development 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: 

production order report

Former Member
0 Kudos
180

REPORT zmtest3 LINE-SIZE 250.

TABLES: aufk, afko, makt, resb.

DATA: BEGIN OF itab OCCURS 0,

aufnr LIKE aufk-aufnr,

erdat LIKE aufk-erdat,

auart LIKE aufk-auart,

  • "meins like aufk-meins,

  • "menge like aufk-menge,

END OF itab.

*data : i type n , j.

DATA desc LIKE makt-maktx.

*DATA DESC2 LIKE resb-MAKTX.

DATA: BEGIN OF itab2 OCCURS 0,

aufnr LIKE afko-aufnr,

gmein LIKE afko-gmein,

gamng LIKE afko-gamng,

plnbez LIKE afko-plnbez,

END OF itab2.

DATA: BEGIN OF itab3 OCCURS 0,

aufnr LIKE resb-aufnr,

enmng LIKE resb-enmng,

bdmng LIKE resb-bdmng,

matnr LIKE resb-matnr,

END OF itab3.

TOP-OF-PAGE.

FORMAT COLOR = 1.

WRITE: 'P O No', 20 'DATE', 32 'TYPE', 45 'UOM', 60 'MATIRIAL NO.', 90 'DESCRIPTION', 120 'ORDERED QTY', 150 'COMPONENT', 170 'DESCRIPTION', 200 ' REQ.QTY', 220 ' ISSUED.QTY' .

ULINE.

START-OF-SELECTION.

SELECT aufnr erdat auart FROM aufk INTO CORRESPONDING FIELDS OF itab.

APPEND itab.

ENDSELECT.

LOOP AT itab INTO itab.

SELECT aufnr gmein gamng plnbez FROM afko INTO CORRESPONDING FIELDS OF itab2 WHERE aufnr = itab-aufnr.

APPEND itab2.

ENDSELECT.

SELECT aufnr enmng bdmng matnr FROM resb INTO CORRESPONDING FIELDS OF itab3 WHERE aufnr = itab-aufnr.

APPEND itab3.

ENDSELECT.

ENDLOOP.

LOOP AT itab.

" WRITE: / itab-aufnr, 20 itab-erdat, 32 itab-auart.

"READ TABLE itab2 WITH KEY aufnr = itab-aufnr.

LOOP AT itab2 WHERE aufnr = itab-aufnr.

"''''''''''''''''''''''''''''''''''''''''''''''''''''''''' write: / ' '.

"endif.

  • IF sy-subrc EQ 0.

SELECT SINGLE maktx INTO desc FROM makt WHERE matnr = itab2-plnbez.

WRITE: / itab-aufnr, 20 itab-erdat, 32 itab-auart.

WRITE: 45 itab2-gmein, 60 itab2-plnbez, 90 desc, 120 itab2-gamng.

  • " endloop.

  • READ TABLE ITAB3 WITH KEY AUFNR = ITAB-AUFNR.

LOOP AT itab3 WHERE aufnr = itab-aufnr.

IF sy-subrc EQ 0.

SELECT SINGLE maktx INTO desc FROM makt WHERE matnr = itab3-matnr.

WRITE: 200 itab3-enmng, 220 itab3-bdmng, 150 itab3-matnr, 170 desc.

ENDIF.

ENDLOOP.

ENDLOOP.

ENDLOOP.

this report produces a report from three tables

but we have multiple values for aufnr in the itab3

but this report shows single values for the itab3-aufnr

like aufnr in itab3 contains

111

112

112

112

113

113

but when i execute this report it shows only

111

112

113

plz help

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos
139

Hi,

Check this


data : v_index type i.
LOOP AT itab3 WHERE aufnr = itab-aufnr.

SELECT SINGLE maktx INTO desc FROM makt WHERE matnr = itab3-matnr.
if v_index eq 0.
  WRITE: 200 itab3-enmng, 220 itab3-bdmng, 150 itab3-matnr, 170 desc.
else.
  WRITE: / 200 itab3-enmng, 220 itab3-bdmng, 150 itab3-matnr, 170 desc.
endif,
v_index = v_index + 1.

ENDLOOP.

aRs

5 REPLIES 5

Former Member
0 Kudos
139

plz help its very urgent

0 Kudos
139

You can start by removing this sy-subrc check as its not needed:

LOOP AT itab3 WHERE aufnr = itab-aufnr.

*IF sy-subrc EQ 0. <<<<remove this

SELECT SINGLE maktx INTO desc FROM makt WHERE matnr = itab3-matnr.

WRITE: 200 itab3-enmng, 220 itab3-bdmng, 150 itab3-matnr, 170 desc.

*ENDIF. <<<<remove this

ENDLOOP.

Former Member
0 Kudos
139

i hav tried this

but it doesnot work

do u hav some other idea

former_member583013
Active Contributor
0 Kudos
139

TABLES: aufk, afko, makt, resb.

DATA: BEGIN OF itab OCCURS 0,
aufnr LIKE aufk-aufnr,
erdat LIKE aufk-erdat,
auart LIKE aufk-auart,
END OF itab.

DATA desc LIKE makt-maktx.

DATA: BEGIN OF itab2 OCCURS 0,
aufnr LIKE afko-aufnr,
gmein LIKE afko-gmein,
gamng LIKE afko-gamng,
plnbez LIKE afko-plnbez,
END OF itab2.

DATA: BEGIN OF itab3 OCCURS 0,
aufnr LIKE resb-aufnr,
enmng LIKE resb-enmng,
bdmng LIKE resb-bdmng,
matnr LIKE resb-matnr,
END OF itab3.

TOP-OF-PAGE.
  FORMAT COLOR = 1.
  WRITE: 'P O No', 20 'DATE', 32 'TYPE', 45 'UOM', 60 'MATIRIAL NO.', 90 'DESCRIPTION', 120 'ORDERED QTY', 150 'COMPONENT', 170 'DESCRIPTION', 200 ' REQ.QTY', 220 ' ISSUED.QTY' .
  ULINE.

START-OF-SELECTION.

  SELECT aufnr erdat auart
  FROM aufk
  INTO CORRESPONDING FIELDS OF TABLE itab.

  SELECT aufnr gmein gamng plnbez
  FROM afko
  INTO CORRESPONDING FIELDS OF TABLE itab2
  FOR ALL ENTRIES IN itab
  WHERE aufnr = itab-aufnr.

  SELECT aufnr enmng bdmng matnr
  FROM resb
  INTO CORRESPONDING FIELDS OF TABLE itab3
  FOR ALL ENTRIES IN itab
  WHERE aufnr = itab-aufnr.

  LOOP AT itab.
    LOOP AT itab2 WHERE aufnr = itab-aufnr.
      SELECT SINGLE maktx INTO desc FROM makt WHERE matnr = itab2-plnbez.
      WRITE: / itab-aufnr, 20 itab-erdat, 32 itab-auart.

      WRITE: 45 itab2-gmein, 60 itab2-plnbez, 90 desc, 120 itab2-gamng.
      LOOP AT itab3 WHERE aufnr = itab-aufnr.
        IF sy-subrc EQ 0.
          SELECT SINGLE maktx INTO desc FROM makt WHERE matnr = itab3-matnr.
          WRITE: 200 itab3-enmng, 220 itab3-bdmng, 150 itab3-matnr, 170 desc.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
  ENDLOOP.

Do this changes in your code...And try to provide some filters so you not get perfomance issues...

In my system I can't get any data, because it's a testing env and we doesn't got all modules filled with data...So I can't help you more than that...To me your code is fine...Should use some FIELD-SYMBOLS, but the logic seems to be Ok.

Greetings,

Blag.

former_member194669
Active Contributor
0 Kudos
140

Hi,

Check this


data : v_index type i.
LOOP AT itab3 WHERE aufnr = itab-aufnr.

SELECT SINGLE maktx INTO desc FROM makt WHERE matnr = itab3-matnr.
if v_index eq 0.
  WRITE: 200 itab3-enmng, 220 itab3-bdmng, 150 itab3-matnr, 170 desc.
else.
  WRITE: / 200 itab3-enmng, 220 itab3-bdmng, 150 itab3-matnr, 170 desc.
endif,
v_index = v_index + 1.

ENDLOOP.

aRs