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

ABAP Program

Former Member
0 Likes
864

hey

i am creating a ABAP program for testing. I need to know the syntax for the following situation. I have a table AUFM, and i want to select AUFNR, BUDAT, MATNR from AUFM and store it in an internal table. there is a selection option used AUFNR which the user enters. i tried writing a select statement, it doesnt give any syntax error but when i run the program , it gives a short dump.

Points will be assigned to helpful answers.

thanks

Laura.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
827

Hi,

Check the changes in bold..

SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS FROM AUFM INTO TYPE_AUFM WHERE AUFNR IN ORDER.

APPEND TYPE_AUFM.

ENDSELECT.

LOOP AT TYPE_AUFM INTO AUFM_WA2.

READ TABLE TYPE_AUFM INDEX SY-TABIX.

WRITE 😕 AUFM_WA2-AUFNR.

ENDLOOP.

<b>OR</b>

SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS FROM AUFM INTO TABLE TYPE_AUFM WHERE AUFNR IN ORDER.

LOOP AT TYPE_AUFM INTO AUFM_WA2.

READ TABLE TYPE_AUFM INDEX SY-TABIX.

WRITE 😕 AUFM_WA2-AUFNR.

ENDLOOP.

Thanks,

Naren

8 REPLIES 8
Read only

Former Member
0 Likes
827

Hi,

Check the order of declaration of the fields in the internal table with the select statement..

DATA: BEGIN OF ITAB OCCURS 0,

AUFNR LIKE AUFM-AUFNR,

BUDAT LIKE AUFM-BUDAT,

MATNR LIKE AUFM-MATNR,

END OF ITAB.

SELECT AUFNR BUDAT MATNR

INTO TABLE ITAB

FROM AUFM.

Thanks,

Naren

Read only

Former Member
0 Likes
827

Can we see your code and let us know the type of dump you are getting.

Rob

Read only

0 Likes
827

DATA : BEGIN OF TYPE_AUFM OCCURS 0,

AUFNR TYPE AUFNR, "ORDER

BWART TYPE BWART, "MOVEMENT TYPE

MATNR TYPE MATNR, "MATERIAL

BUDAT TYPE BUDAT, "POSTING DATE

WERKS TYPE WERKS, "PLANT

LGORT TYPE LGORT_D, "STORAGE LOCATION

MENGE TYPE MENGE_D, "QUANTITY IN BASE UNIT

MEINS TYPE MEINS, "BASE UNIT

  • VORNR TYPE VORNR,

  • ARBPL TYPE ARBPL,

END OF TYPE_AUFM.

*DATA: AUFM_ITAB TYPE TYPE_AUFM OCCURS 0 WITH HEADER LINE.

DATA : AUFM_ITAB LIKE TYPE_AUFM.

DATA : AUFM_WA2 LIKE AUFM_ITAB.

SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS FROM AUFM INTO TYPE_AUFM WHERE AUFNR IN ORDER.

ENDSELECT.

LOOP AT TYPE_AUFM INTO AUFM_WA2.

READ TABLE TYPE_AUFM INDEX SY-TABIX.

WRITE 😕 AUFM_WA2-AUFNR.

ENDLOOP.

i wrote the above code, its not giving a short dump now, but it doesnt display any result ??

Read only

0 Likes
827

Try:


SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS  
  FROM AUFM 
  INTO TABLE TYPE_AUFM
  WHERE AUFNR IN ORDER.

No ENDSELECT.

rob

Read only

0 Likes
827

Hi,

Use the below code

types : BEGIN OF TYPE_AUFM OCCURS 0,

AUFNR TYPE AUFNR, "ORDER

BWART TYPE BWART, "MOVEMENT TYPE

MATNR TYPE MATNR, "MATERIAL

BUDAT TYPE BUDAT, "POSTING DATE

WERKS TYPE WERKS, "PLANT

LGORT TYPE LGORT_D, "STORAGE LOCATION

MENGE TYPE MENGE_D, "QUANTITY IN BASE UNIT

MEINS TYPE MEINS, "BASE UNIT

END OF TYPE_AUFM.

types: ITAB TYPE standard table of TYPE_AUFM.

DATA : AUFM_ITAB TYPE ITAB.

DATA : AUFM_WA2 TYPE TYPE_AUFM.

SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS FROM AUFM INTO TYPE_AUFM2 WHERE AUFNR IN ORDER.

APPEND TYPE_AUFM2 to AUFM_ITAB .

clear TYPE_AUFM2.

ENDSELECT

LOOP AT AUFM_ITAB INTO AUFM_WA2.

WRITE 😕 AUFM_WA2-AUFNR.

ENDLOOP.

Regards,

Vara

Read only

Former Member
0 Likes
827

Hi,

the problem could be with the internal table declaration.

Whenever you use SELECT ... INTO TABLE ....statement...make sure that the sequence of fields used in the select statement is same as the the sequence of fields in the internal table. If the sequence does not match, then the program gives a dump. To avoid this change the sequence of fields either in the internal table or in the select statement or use SELECT ... INTO CORRESPONDING FIELDS OF TABLE statement.

Regards,

Vara

Read only

ferry_lianto
Active Contributor
0 Likes
827

Hi,

Please try this.


SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS
FROM AUFM 
INTO TABLE TYPE_AUFM 
ORDER BY AUFNR.

LOOP AT TYPE_AUFM INTO AUFM_WA2.
READ TABLE TYPE_AUFM INDEX SY-TABIX.
WRITE :/ AUFM_WA2-AUFNR.
ENDLOOP.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
828

Hi,

Check the changes in bold..

SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS FROM AUFM INTO TYPE_AUFM WHERE AUFNR IN ORDER.

APPEND TYPE_AUFM.

ENDSELECT.

LOOP AT TYPE_AUFM INTO AUFM_WA2.

READ TABLE TYPE_AUFM INDEX SY-TABIX.

WRITE 😕 AUFM_WA2-AUFNR.

ENDLOOP.

<b>OR</b>

SELECT AUFNR BWART MATNR BUDAT WERKS LGORT MENGE MEINS FROM AUFM INTO TABLE TYPE_AUFM WHERE AUFNR IN ORDER.

LOOP AT TYPE_AUFM INTO AUFM_WA2.

READ TABLE TYPE_AUFM INDEX SY-TABIX.

WRITE 😕 AUFM_WA2-AUFNR.

ENDLOOP.

Thanks,

Naren