Skip to Content
-3

Modify internal table not working on some field (MATERIAL_EXTERNAL)

I am working on 'BAPI_GOODSMVT_GETDETAIL'.
I want to add material desception to the table ('GOODSMVT_ITEMS') return from this BAPI,

I copy 'BAPI_GOODSMVT_GETDETAIL' to 'ZBAPI_GOODSMVT_GETDETAIL'.
Then added the code below to load material description into the internal table where I want to put the desctiption at 'material_external' field. However when I tested the function, the material_external field in the internal table is not updated. I tried to put in item_text field instead and it works. Why is material_material field not working?

LOOP AT GOODSMVT_ITEMS INTO WA_GOODSMVT_ITEM .
  SELECT MAKTX FROM MAKT INTO MATERIAL_EXTERNAL
    WHERE MATNR = WA_GOODSMVT_ITEM-MATERIAL.
    ENDSELECT.

    WA_GOODSMVT_ITEM-MATERIAL_EXTERNAL = MATERIAL_EXTERNAL.

    MODIFY GOODSMVT_ITEMS FROM WA_GOODSMVT_ITEM INDEX sy-tabix
    TRANSPORTING MATERIAL_EXTERNAL.
  ENDLOOP.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 13 at 04:58 AM

    A few points.

    1. Never copy standard SAP code into your own name space. It is more dangerous than making a modification to the SAP code. Read my comment on this question https://archive.sap.com/discussions/thread/3617361

    2. If you're looping through an internal table, don't use MODIFY. Instead using LOOP AT ... ASSIGNING... Search for examples of how this works. Or read the documentation.

    3. With select endselect, you are looping through all entries in MAKT that have that particular MATNR, and ending up on the last one. How's that going to work on a multi-language system? Use SELECT SINGLE and specify the full key.


    Add comment
    10|10000 characters needed characters exceeded

    • Hi Matthew,

      In debug mode, I did see the variables, both <fs>-material and <fs>-material_external change.
      I also placed a breakpoint after the loop ends, which I see that material_external in the internal table is set.
      But when the funcation ends, in the return table the material_external is again empty.

  • Apr 17 at 10:29 AM

    Hi Pawadee,

    Material External is not the description field. Material has been represented in internal and external format.

    When you try to put the material external , it is validating with the existing material.

    you can check domain MATNR_EXT for more information on conversion.

    Hope you can took advice from Matthew for not copy standard BAPI.

    Regards

    Himanshu

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Himanshu,

      Thank you for explaining, now I get it.

      I was kind of try to sneak in the description into the field so that I don't need to create my own structure with description field since I saw that it have the same length etc.

      And yes, I did took Matthew advice :)