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: 

my code is not working tell me the answer

Former Member
0 Kudos

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: WA_ITAB LIKE LINE OF ITAB.

SELECT MATKL FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'.

LOOP AT ITAB INTO WA_ITAB.

WRITE : WA_ITAB-MATKL.

ENDLOOP.

it is syntically correct but o/p is not coming

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ansuman,

Please check this

MATNR = '000000000000521196'.

Please check wheather the ITAB is getting populated or not.

Best regards,

raam

14 REPLIES 14

Former Member
0 Kudos

Write your select stmt this way.

SELECT MATKL FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR = '521196'.

REGARDS,

aZAD.

Former Member
0 Kudos

Hi,

Write INTO CORRESPONDING FIELDS OF ITAB.

Former Member
0 Kudos

Hi Ansuman,

Please check this

MATNR = '000000000000521196'.

Please check wheather the ITAB is getting populated or not.

Best regards,

raam

Former Member
0 Kudos

HI,

change the internal table structure to the retriving variables in SELECT conditon.

DATA: BEGIN OF ITAB OCCURS 0,
MATKL LIKE MARA-MATKL,
END OF ITAB.

or change the select condition

SELECT MATNR 
           MTART
          MATKL
     UOM
      LAEDA
        FROM MARA 
   INTO TABLE ITAB 
WHERE MATNR = '521196'.

Former Member
0 Kudos

Hi,

The length of the matnr is 18 and the value you are passing is not equal to length of the matnr, add zeros infront of the matnr you passed or conversion exit.

Thanks,

Sriram Ponna.

former_member705122
Active Contributor
0 Kudos

Hi,

your code is ok make but requires some changes

DATA: BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
UOM LIKE MARA-MEINS,
LAEDA LIKE MARA-LAEDA,
END OF ITAB.


DATA: WA_ITAB LIKE LINE OF ITAB.


SELECT MATKL FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'.

LOOP AT ITAB.
WRITE : ITAB-MATKL.
ENDLOOP.

Either use the table with header line or with work area.

Regards

Adil

Former Member
0 Kudos

either use 'into corresponding fields of ' addition or write the query as follows....

SELECT MATNR MTART MATKL MEINS LAEDA FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'.

Former Member
0 Kudos

hi,

Do like this.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: WA_ITAB LIKE LINE OF ITAB.

SELECT MATKL FROM MARA INTO CORRESPONDING FIELDS FOF TABLE ITAB WHERE MATNR = '521196'.

IF SY-SUBRC = 0. // see whether subrc is 0 or not if it is 0 then ur select stmt is right , eventhough u r not getting data into internal table may be data is not available in table mara.LOOP AT ITAB INTO WA_ITAB.

WRITE : WA_ITAB-MATKL.

ENDLOOP.

ENDIF.

Rgds.

subash

Former Member
0 Kudos

Before passing the value in to select condition,

pass the value to FM: CONVERSION_EXIT_MATN1_INPUT and pass this value to Select.

In select condition INTO CORRESPONDING FIELDS OF TABLE should be used instead of INTO TABLE.

Regards

Kannaiah

Former Member
0 Kudos

plz check whether in the database table there exist a value which you have given in the where clause.

that is in the database it is not satisfying the where clause

write this loop at itab into wa.

dont give where clause fr the time being

if value comes then give where clause with where clause and check...

Former Member
0 Kudos

hi,

write your code like this.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: v_matnr type mara-matnr..

v_matnr = '521196' .

SELECT MATKL FROM MARA INTO TABLE ITAB WHERE MATNR = v_matnr.

LOOP AT ITAB.

WRITE : ITAB-MATKL.

ENDLOOP.

Former Member
0 Kudos

hi,

just use "INTO CORRESPONDING FIELDS OF " in the select statement.

Regards,

venkat n

Former Member
0 Kudos

See my comments (marked in bold) below:

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL, << Keep only matkl and remove other fields

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: WA_ITAB LIKE LINE OF ITAB.

SELECT MATKL FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'. << Give material name with 18 char length

<< check sy-subrc value to detemine whether any record is selected or not

LOOP AT ITAB INTO WA_ITAB.

WRITE : WA_ITAB-MATKL. << Check the value of WA_ITAB-MATKL, it can be blank in that case you will get blank output

ENDLOOP.

Former Member
0 Kudos

Hi,

Try this it will surely work.

TABLES : MARA.

TYPES: BEGIN OF ITAB ,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL TYPE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: I_ITAB TYPE STANDARD TABLE OF ITAB,

WA_ITAB LIKE LINE OF I_ITAB,

LV_MATNR LIKE MARA-MATNR.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

INPUT = '59'

IMPORTING

OUTPUT = LV_MATNR

  • EXCEPTIONS

  • LENGTH_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

SELECT MATKL FROM MARA INTO CORRESPONDING FIELDS OF TABLE I_ITAB WHERE MATNR = LV_MATNR.

IF SY-SUBRC EQ 0.

LOOP AT I_ITAB INTO WA_ITAB.

WRITE : WA_ITAB-MATKL.

ENDLOOP.

ELSE.

MESSAGE E003.

ENDIF.

Plz reward if useful.

Thanks,

Dhanashri.