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: 

Assign value to import parameter table

Former Member
0 Kudos

Hello All:

I am very new to ABAP programming.

I have a code looks like below, where ORDER_ITEM_IN is a BAPIITEMIN TYPE. And it's a table passed in as parameter. I am looping through the table to find referenced material from CUST_MAT. But when I try to assign the found value to ORDER_ITEM_IN-MATERIAL, nothing is done. I still have a empty space even though the IMARA-MATNR return correctly. What am I doing wrong? Please let me know, this is urgent!

LOOP AT ORDER_ITEM_IN.

Call function 'CONVERSION_EXIT_ALPHA_OUTPUT'

Exporting

input = ORDER_ITEM_IN-CUST_MAT

Importing

output = strx.

READ TABLE IMARA WITH KEY EAN11 = strx.

strx = IMARA-MATNR.

if IMARA-MATNR NE SPACE.

ORDER_ITEM_IN-MATERIAL = IMARA-MATNR.

ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


DATA: strx type matnr.

LOOP AT ORDER_ITEM_IN.

  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input = ORDER_ITEM_IN-CUST_MAT
    importing
      output = strx.

  READ TABLE IMARA WITH KEY EAN11 = strx.

  strx = IMARA-MATNR.

  IF IMARA-MATNR NE SPACE.
    ORDER_ITEM_IN-MATERIAL = IMARA-MATNR.
  ENDIF.

  MODIFY ORDER_ITEM_IN.

ENDLOOP. 

Regards,

Ferry Lianto

6 REPLIES 6

Former Member
0 Kudos

Hi,

Declare strx as matnr.

DATA: STRX TYPE MATNR.

Reward if it helps,

Satish

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


DATA: strx type matnr.

LOOP AT ORDER_ITEM_IN.

  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input = ORDER_ITEM_IN-CUST_MAT
    importing
      output = strx.

  READ TABLE IMARA WITH KEY EAN11 = strx.

  strx = IMARA-MATNR.

  IF IMARA-MATNR NE SPACE.
    ORDER_ITEM_IN-MATERIAL = IMARA-MATNR.
  ENDIF.

  MODIFY ORDER_ITEM_IN.

ENDLOOP. 

Regards,

Ferry Lianto

0 Kudos

Sorry. Tried, doesn't work

The ORDER_ITEM_IN is a parameter table, it's not a local table. I don't know if this make sense, but when I call this BAPI ORDER_ITEM_IN. Is that what's causing the problem?

I also have tried to move it to a internal table and modify, doesn't work either! Getting frustrated!

TABLES

*" ORDER_ITEM_IN STRUCTURE BAPIITEMIN

0 Kudos

Did you try like this:

DATA: strx type matnr.
 
data: itab like BAPIITEMIN  occurs 0 with header line.

itab[] = ORDER_ITEM_IN[].

LOOP AT itab.
 
  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input = itab-CUST_MAT
    importing
      output = strx.
 
  READ TABLE IMARA WITH KEY EAN11 = strx.
  if sy-subrc = 0.    "<<< 
  strx = IMARA-MATNR.
  endif.
  IF IMARA-MATNR is not initial. " <<<
    itab-MATERIAL = IMARA-MATNR.
  ENDIF.
  MODIFY itab.
  endif.
ENDLOOP. 

ORDER_ITEM_IN[] = itab[].

Regards,

Naimesh Patel

0 Kudos

Thank You Naimesh.

This worked fine. however I didn't use a temp table, I just modified the input table. Test out ok, but I wonder if there are possible problem in the future!

0 Kudos

I think there will not be any..

Regards,

Naimesh Patel