cancel
Showing results for 
Search instead for 
Did you mean: 

Can BAPI_ASSORTMENT_MAINTAINDATA change data?

former_member797394
Participant
0 Kudos

Hello everyone,

I have written a program that adds assortment module (LOCNR) to an existing assortment (FILIA). It works fine. However, now I need to change the date value_to (DATBI) to todays date, in order to make this assortment module (LOCNR) invalid, means out-of-date. Can I do this with the help of this BAPI? If yes, then how, because I have tried to do this on my own, but the date is not changed. Here is the piece of my code, where I try to change the date value:

wa_assortmentusers-valid_from = ls_info-datab.
SELECT SINGLE datbi INTO wa_assortmentusers-valid_to FROM wrsz 
WHERE asort EQ wa_assortmentusers-assortment
AND locnr EQ wa_assortmentusers-customer_site.
IF sy-subrc EQ 0.
wa_assortmentusers-valid_to = ls_info-datbi.
ELSE.
wa_assortmentusers-valid_to = ls_info-datbi.
ENDIF.
wa_assortmentusersx-valid_from = 'X'.
wa_assortmentusersx-valid_to = 'X'.


Any ideas?

FredericGirod
Active Contributor
0 Kudos

Do you have something in the RETURN structure ?

Do you have add a BAPI_TRANSACTION_COMMIT after the successfull call of your BAPI ?

Why do you specify to change the VALID_FROM value and doesn't populate the value in wa_assortmentuser structure ?

former_member797394
Participant
0 Kudos

frdric.girod

hello,1 - yes, I do have something in my return, here is code (let me know, if smth wrong with it, please):ld_return TYPE bapiret2.
CALL FUNCTION 'BAPI_ASSORTMENT_MAINTAINDATA'
IMPORTING
return = ld_return
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
ENDIF.
WRITE: ld_return-message.
2 - yes, I do have. You can see it in the above code.3 - I do not really understand what you mean. What do you mean by "doesn't populate the value in wa_assortmentuser structure"
FredericGirod
Active Contributor
0 Kudos

this is your full code ? how did you send the data to the function ?

former_member797394
Participant
0 Kudos

here is a piece of code, where I am sending data:

 LOOP AT mt_info INTO ls_info.
TRANSLATE ls_info-asort TO UPPER CASE.
wa_assortment-assortment = ls_info-asort.
wa_assortmentx-assortment = 'X'.
wa_assortmentusers-assortment = ls_info-asort.
wa_assortmentusers-customer_site = ls_info-locnr.
SELECT SINGLE lfdnr INTO wa_assortmentusers-seqnumber FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment
AND locnr EQ wa_assortmentusers-customer_site
AND datbi GT sy-datum.
IF sy-subrc NE 0.
SELECT MAX( lfdnr ) INTO wa_assortmentusers-seqnumber FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment.
IF sy-subrc EQ 0.
wa_assortmentusers-seqnumber = wa_assortmentusers-seqnumber + loop_num.
ELSEIF sy-subrc NE 0.
wa_assortmentusers-seqnumber = loop_num.
ENDIF.
ENDIF.
wa_assortmentusers-salesorg = '1100'.
wa_assortmentusers-distr_chan = '10'.
wa_assortmentusers-division = '01'.
wa_assortmentusers-astmtuserc = 'A'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = ls_info-datab
* ACCEPT_INITIAL_DATE =
IMPORTING
DATE_INTERNAL = ls_info-datab
* EXCEPTIONS
* DATE_EXTERNAL_IS_INVALID = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
wa_assortmentusers-valid_from = ls_info-datab.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = ls_info-datbi
* ACCEPT_INITIAL_DATE =
IMPORTING
DATE_INTERNAL = ls_info-datbi
* EXCEPTIONS
* DATE_EXTERNAL_IS_INVALID = 1
* OTHERS = 2
.
SELECT SINGLE datbi INTO wa_assortmentusers-valid_to FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment
AND locnr EQ wa_assortmentusers-customer_site.
IF sy-subrc EQ 0.
wa_assortmentusers-valid_to = ls_info-datbi.
ELSE.
wa_assortmentusers-valid_to = ls_info-datbi.
ENDIF.
wa_assortmentusersx-assortment = 'X'.
wa_assortmentusersx-seqnumber = 'X'.
wa_assortmentusersx-customer_site = 'X'.
wa_assortmentusersx-salesorg = 'X'.
wa_assortmentusersx-distr_chan = 'X'.
wa_assortmentusersx-division = 'X'.
wa_assortmentusersx-astmtuserc = 'X'.
wa_assortmentusersx-valid_from = 'X'.
wa_assortmentusersx-valid_to = 'X'.
APPEND wa_assortmentusers TO it_assortmentusers.
APPEND wa_assortmentusersx TO it_assortmentusersx.
loop_num = loop_num + 1.
CLEAR wa_assortmentusers.
CLEAR wa_assortmentusersx.
ENDLOOP.
CALL FUNCTION 'BAPI_ASSORTMENT_MAINTAINDATA'
EXPORTING
assortment = wa_assortment
assortmentx = wa_assortmentx
IMPORTING
return = ld_return
TABLES
* MATERIALGROUP =
* MATERIALGROUPX =
* DESCRIPTION =
* DESCRIPTIONX =
assortmentusers = it_assortmentusers
assortmentusersx = it_assortmentusersx.
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
LOOP AT it_assortmentusers INTO wa_assortmentusers.
WRITE: ld_return-message,
wa_assortmentusers-customer_site, 'Добавлен в куб', wa_assortmentusers-assortment,
/.
ENDLOOP.
ENDIF.
floydiericany
Discoverer
0 Kudos

Yes it can, I had to debug that FM a little bit to find how. You don't need to use any Batch input as some colleague above me, you just have to take care of SeqNumbers. This method can change existing assignment (change validity dates) or create a new one. You just have to adjust it to your needs.

 METHOD assign.
    DATA: ld_entry_found TYPE boolean.

    cleanup( ). "clear static attributes

    "check if debitor exists and is relevant for Retail
    SELECT SINGLE werks INTO @DATA(werks) FROM t001w WHERE kunnr = @id_customer.
    IF sy-subrc <> 0.
      RAISE EXCEPTION TYPE zcx_assortment
        EXPORTING
          textid   = zcx_assortment=>invalid_debitor
          customer = id_customer.
    ENDIF.

    "check dates
    IF id_from > id_to.
      RAISE EXCEPTION TYPE zcx_assortment
        EXPORTING
          textid = zcx_assortment=>invalid_dates.
    ENDIF.

    "check if assortment exists
    SELECT SINGLE asort INTO @DATA(dummy) FROM wrs1 WHERE asort = @id_assortment.
    IF sy-subrc <> 0.
      RAISE EXCEPTION TYPE zcx_assortment
        EXPORTING
          textid     = zcx_assortment=>assortment_doesnt_exist
          assortment = id_assortment.
    ENDIF.

    "prepare BAPI call

    "BAPI Function codes
    "003 Delete: Message contains objects to be deleted.
    "004 Change: Message contains changes
    md_assort-assortment = id_assortment.
    md_assortx-assortment = id_assortment.
    md_assort-function = '004'.
    md_assortx-assortment = '004'.


    md_users-assortment = id_assortment.
    md_usersx-assortment = id_assortment.
    md_users-function = '004'.
    md_usersx-function = '004'.

    md_users-customer_site = id_customer.
    md_users-astmtuserc = 'A'.
    md_users-salesorg = 'V001'.
    md_users-distr_chan = 'V2'.
    md_users-division = 'S0'.


    "find valid existing entry + we need sequence number
    SELECT SINGLE lfdnr INTO @md_users-seqnumber FROM wrsz
      WHERE asort = @id_assortment AND locnr = @id_customer AND datbi >= @sy-datum.
    IF sy-subrc = 0.
      ld_entry_found = abap_true.
      md_usersx-seqnumber = md_users-seqnumber.
    ENDIF.

    IF id_to < sy-datum. "end active assignment

      IF ld_entry_found = abap_true. "entry found
        md_users-valid_to = id_to.
        md_usersx-valid_to = abap_true.
      ELSE. "no such active assortment found, exit method
        RETURN.
      ENDIF.

    ELSE. "add new/change existing assignment


      "INFO there can be existing assortment which is not valid anymore,
      "but if we don't provide new Sequence Number, system can modify old entry (with empty SeqNum) and don't create a new one
      IF ld_entry_found = abap_false. "check for older entries and generate SeqNumber

        SELECT MAX( lfdnr ) AS lfdnr INTO @DATA(new_sequence) FROM wrsz
         WHERE asort = @id_assortment AND locnr = @id_customer.
        IF sy-subrc = 0.
          md_users-seqnumber = new_sequence + 1.
          md_usersx-seqnumber = md_users-seqnumber.
        ENDIF.

      ENDIF.


      md_users-valid_from = id_from.
      md_users-valid_to = id_to.

      md_usersx-valid_from = abap_true.
      md_usersx-valid_to = abap_true.
      md_usersx-customer_site = abap_true.
      md_usersx-astmtuserc = abap_true.
      md_usersx-salesorg = abap_true.
      md_usersx-distr_chan = abap_true.
      md_usersx-division = abap_true.

    ENDIF.

    APPEND md_users TO mt_users.
    APPEND md_usersx TO mt_usersx.

    CALL FUNCTION 'BAPI_ASSORTMENT_MAINTAINDATA'
      EXPORTING
        assortment       = md_assort
        assortmentx      = md_assortx
      IMPORTING
        return           = md_return
      TABLES
        assortmentusers  = mt_users
        assortmentusersx = mt_usersx.

    IF md_return IS INITIAL.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    ENDIF.


  ENDMETHOD.
floydiericany
Discoverer
0 Kudos

Just in case you want to implement it.

Method "assign" signature

ID_CUSTOMER TYPE LOCNR Customer Number for Plant

ID_ASSORTMENT TYPE ASORT Assortment

ID_FROM TYPE DATAB Valid-From Date

ID_TO TYPE DATBI Valid To Date

ZCX_ASSORTMENT Assortment exception class

Class static attributes

MD_RETURN Static Attribute Private Type BAPIRET2

MD_ASSORT Static Attribute Private Type BAPIE1WRS1

MD_ASSORTX Static Attribute Private Type BAPIE1WRS1X

MD_USERS Static Attribute Private Type BAPIE1WRSZ

MD_USERSX Static Attribute Private Type BAPIE1WRSZX

MT_USERS Static Attribute Private Type TY_T_BAPIE1WRSZ

MT_USERSX Static Attribute Private Type TY_T_BAPIE1WRSZX

Accepted Solutions (1)

Accepted Solutions (1)

former_member797394
Participant
0 Kudos
LOOP AT mt_info INTO ls_info.
TRANSLATE ls_info-asort TO UPPER CASE.
SELECT SINGLE name1 INTO ls_info-name1 FROM wrst WHERE asort EQ ls_info-asort.
wa_assortment-assortment = ls_info-asort.
SELECT SINGLE sotyp INTO wa_assortment-astmt_cat FROM wrs1 WHERE asort EQ wa_assortment-assortment.
wa_assortmentx-astmt_cat = 'X'.
wa_assortmentx-assortment = 'X'.
wa_assortmentusers-assortment = ls_info-asort.
wa_assortmentusers-customer_site = ls_info-locnr.
SELECT SINGLE lfdnr INTO wa_assortmentusers-seqnumber FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment
AND locnr EQ wa_assortmentusers-customer_site
AND datbi GT sy-datum.
IF sy-subrc NE 0.
SELECT MAX( lfdnr ) INTO wa_assortmentusers-seqnumber FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment.
IF sy-subrc EQ 0.
wa_assortmentusers-seqnumber = wa_assortmentusers-seqnumber + loop_num.
ELSEIF sy-subrc NE 0.
wa_assortmentusers-seqnumber = loop_num.
ENDIF.
ENDIF.
wa_assortmentusers-salesorg = '1100'.
wa_assortmentusers-distr_chan = '10'.
wa_assortmentusers-division = '01'.
wa_assortmentusers-astmtuserc = 'A'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = ls_info-datab
IMPORTING
date_internal = ls_info-datab.
wa_assortmentusers-valid_from = ls_info-datab.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = ls_info-datbi
IMPORTING
date_internal = ls_info-datbi
SELECT locnr INTO wa_wrsz-locnr FROM wrsz WHERE asort EQ wa_assortment-assortment
AND datbi GT sy-datum.
APPEND wa_wrsz TO it_wrsz.
SORT it_wrsz.
CLEAR wa_wrsz.
ENDSELECT.
LOOP AT it_wrsz INTO wa_wrsz.
date_cy = date_cy + 1.
IF wa_wrsz-locnr EQ wa_assortmentusers-customer_site.
EXIT.
ENDIF.
ENDLOOP.
CONDENSE date_cy NO-GAPS.
CONCATENATE 'MARK_040(' date_cy ')' INTO ld_mark.
CONCATENATE 'V_WRSZ-LOCNR(' date_cy ')' INTO ld_cursor.
CLEAR date_cy.
CLEAR it_wrsz.
CLEAR wa_wrsz.
SELECT SINGLE datbi INTO wa_assortmentusers-valid_to FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment
AND locnr EQ wa_assortmentusers-customer_site
AND datbi GE sy-datum.
IF sy-subrc EQ 0.
IF ls_info-datbi LT wa_assortmentusers-valid_to.
wa_assortmentusers-valid_to = ls_info-datbi.
wa_description-function = '003'.
wa_description-assortment = ls_info-asort.
wa_descriptionx-function = 'X'.
wa_descriptionx-assortment = 'X'.
cycle = 1.
PERFORM fill_bdcdata USING ls_info.
run_mode = 'E'.
CALL TRANSACTION 'WSOA2'
USING bdcdata MODE run_mode UPDATE 'S' MESSAGES INTO lt_msg.
ENDIF.
ELSE.
wa_assortmentusers-valid_to = ls_info-datbi.
ENDIF.
wa_assortmentusersx-assortment = 'X'.
wa_assortmentusersx-seqnumber = 'X'.
wa_assortmentusersx-customer_site = 'X'.
wa_assortmentusersx-salesorg = 'X'.
wa_assortmentusersx-distr_chan = 'X'.
wa_assortmentusersx-division = 'X'.
wa_assortmentusersx-astmtuserc = 'X'.
wa_assortmentusersx-valid_from = 'X'.
wa_assortmentusersx-valid_to = 'X'.
APPEND wa_assortmentusers TO it_assortmentusers.
APPEND wa_assortmentusersx TO it_assortmentusersx.
APPEND wa_description TO it_description.
APPEND wa_descriptionx TO it_descriptionx.
loop_num = loop_num + 1.
CLEAR wa_assortmentusers.
CLEAR wa_assortmentusersx.
ENDLOOP.
CALL FUNCTION 'BAPI_ASSORTMENT_MAINTAINDATA'
EXPORTING
assortment = wa_assortment
assortmentx = wa_assortmentx
IMPORTING
return = ld_return
TABLES
description = it_description
descriptionx = it_descriptionx
assortmentusers = it_assortmentusers
assortmentusersx = it_assortmentusersx.
IF cycle EQ 1.
LOOP AT it_assortmentusers INTO wa_assortmentusers.
WRITE: ld_return-message,
wa_assortmentusers-customer_site, 'Удален из куба', wa_assortmentusers-assortment,
/.
ENDLOOP.
ELSE.
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
LOOP AT it_assortmentusers INTO wa_assortmentusers.
WRITE: ld_return-message,
wa_assortmentusers-customer_site, 'Добавлен в куб', wa_assortmentusers-assortment,
/.
ENDLOOP.
ENDIF.
ENDIF.
FORM fill_bdcdata USING is_info   TYPE zmm_kub.
REFRESH bdcdata.
* 1st screen.
PERFORM bdc_dynpro USING 'WRFM_WSO6' '0001'.
PERFORM bdc_field USING 'BDC_CURSOR' 'V_WRS1-ASORT'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTR'.
PERFORM bdc_field USING 'V_WRS1-ASORT' is_info-asort.
* 2nd screen.
PERFORM bdc_dynpro USING 'WRFM_WSO6' '0010'.
PERFORM bdc_field USING 'BDC_CURSOR' 'V_WRS1-NAME1'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ASORT_TAB_FC4'.
PERFORM bdc_field USING 'V_WRS1-NAME1' is_info-name1.
PERFORM bdc_field USING 'V_WRS1-STATU' '1'.
PERFORM bdc_field USING 'V_WRS1-VKORG' '1100'.
PERFORM bdc_field USING 'V_WRS1-VTWEG' '10'.
PERFORM bdc_field USING 'V_WRS1-KZLIK' 'X'.
PERFORM bdc_field USING 'V_WRS1-LAYPR' 'X'.
* 3rd screen.
PERFORM bdc_dynpro USING 'WRFM_WSO6' '0010'.
PERFORM bdc_field USING 'BDC_OKCODE' '/EDEL'.
PERFORM bdc_field USING 'V_WRS1-NAME1' is_info-name1.
PERFORM bdc_field USING 'BDC_CURSOR' ld_cursor.
PERFORM bdc_field USING ld_mark 'X'.
CLEAR ld_mark.
* 4th screen.
PERFORM bdc_dynpro USING 'WRFM_WSO6' '0010'.
PERFORM bdc_field USING 'BDC_OKCODE' '=XSI'.
PERFORM bdc_field USING 'V_WRS1-NAME1' is_info-name1.
PERFORM bdc_field USING 'BDC_CURSOR' ld_cursor.
CLEAR ld_cursor.
ENDFORM.
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM.
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
CONDENSE bdcdata-fval.
* REPLACE FIRST OCCURRENCE OF '.' in bdcdata-fval WITH ','.
APPEND bdcdata.
ENDFORM.

Answers (1)

Answers (1)

venkateswaran_k
Active Contributor
0 Kudos

Hi

You can use the same BAPI

The table BAPIE1WRST-FUNCTION = assign 003 code to this field

003 = is to delete

004 = is to change

You can see the domain of this data item BAPIE1WRST-FUNCTION

Use - structure BAPIE1WRST-FUNCTION to be passed with 003 for delete 

CALL FUNCTION 'BAPI_ASSORTMENT_MAINTAINDATA' "Maintenance of Assortments
  EXPORTING
    assortment =                " bapie1wrs1
    assortmentx =               " bapie1wrs1x
  IMPORTING
    return =                    " bapiret2
* TABLES
*   materialgroup =             " bapie1wrs6
*   materialgroupx =            " bapie1wrs6x
*   description =               " bapie1wrst     <====== pass the code 003
*   descriptionx =              " bapie1wrstx
*   assortmentusers =           " bapie1wrsz
*   assortmentusersx =          " bapie1wrszx
    .  "  BAPI_ASSORTMENT_MAINTAINDATA<br>

Regards,

Venkat

venkateswaran_k
Active Contributor

Hi khasanyusupkhujaev

Are you able to change / delete the existing data using this BAPI

As per documentation, this BAPI is used for create/change/delete as well.

former_member797394
Participant
0 Kudos

Hello venkateswaran.k,

I have not tried yet. I will let you know as soon as I will have any positive or negative results. Kindly ask you to keep in touch.

Thank you, much appreciated.

former_member797394
Participant
0 Kudos

venkateswaran.k,

Should it look something like this? I have made bold the lines that you should pay attantion. I am checking there, if the date in the table is grater than the date I want to send via my excel file. If yes, then give description value 003 and descriptionx X. That did not work for me, unfortanetely. Am I doing something wrong?

Data:
it_description TYPE STANDARD TABLE OF bapie1wrst,
wa_description LIKE LINE OF it_description,
it_descriptionx TYPE STANDARD TABLE OF bapie1wrstx,
wa_descriptionx LIKE LINE OF it_descriptionx.
LOOP AT mt_info INTO ls_info.
TRANSLATE ls_info-asort TO UPPER CASE.
wa_assortment-assortment = ls_info-asort.
wa_assortmentx-assortment = 'X'.
wa_assortmentusers-assortment = ls_info-asort.
wa_assortmentusers-customer_site = ls_info-locnr.
SELECT SINGLE lfdnr INTO wa_assortmentusers-seqnumber FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment
AND locnr EQ wa_assortmentusers-customer_site
AND datbi GT sy-datum.
IF sy-subrc NE 0.
SELECT MAX( lfdnr ) INTO wa_assortmentusers-seqnumber FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment.
IF sy-subrc EQ 0.
wa_assortmentusers-seqnumber = wa_assortmentusers-seqnumber + loop_num.
ELSEIF sy-subrc NE 0.
wa_assortmentusers-seqnumber = loop_num.
ENDIF.
ENDIF.
wa_assortmentusers-salesorg = '1100'.
wa_assortmentusers-distr_chan = '10'.
wa_assortmentusers-division = '01'.
wa_assortmentusers-astmtuserc = 'A'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = ls_info-datab
* ACCEPT_INITIAL_DATE =
IMPORTING
date_internal = ls_info-datab
* EXCEPTIONS
* DATE_EXTERNAL_IS_INVALID = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
wa_assortmentusers-valid_from = ls_info-datab.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = ls_info-datbi
* ACCEPT_INITIAL_DATE =
IMPORTING
date_internal = ls_info-datbi
* EXCEPTIONS
* DATE_EXTERNAL_IS_INVALID = 1
* OTHERS = 2
.
SELECT SINGLE datbi INTO wa_assortmentusers-valid_to FROM wrsz
WHERE asort EQ wa_assortmentusers-assortment
AND locnr EQ wa_assortmentusers-customer_site
AND datbi GE sy-datum.
IF sy-subrc EQ 0.
IF ls_info-datbi LT wa_assortmentusers-valid_to.
wa_description-function = 003.
wa_description-assortment = ls_info-asort.
wa_descriptionx-function = 'X'.
wa_descriptionx-assortment = 'X'.
wa_assortmentusers-valid_to = ls_info-datbi.
wa_description-assortment = ls_info-asort.
wa_descriptionx-function = 'X'.
wa_descriptionx-assortment = 'X'.
wa_assortmentusers-valid_to = ls_info-datbi.
ENDIF.
ELSE.
wa_assortmentusers-valid_to = ls_info-datbi.
ENDIF.
wa_assortmentusersx-assortment = 'X'.
wa_assortmentusersx-seqnumber = 'X'.
wa_assortmentusersx-customer_site = 'X'.
wa_assortmentusersx-salesorg = 'X'.
wa_assortmentusersx-distr_chan = 'X'.
wa_assortmentusersx-division = 'X'.
wa_assortmentusersx-astmtuserc = 'X'.
wa_assortmentusersx-valid_from = 'X'.
wa_assortmentusersx-valid_to = 'X'.
APPEND wa_assortmentusers TO it_assortmentusers.
APPEND wa_assortmentusersx TO it_assortmentusersx.
APPEND wa_description TO it_description.
APPEND wa_descriptionx TO it_descriptionx.
APPEND wa_descriptionx TO it_descriptionx.
loop_num = loop_num + 1.
CLEAR wa_assortmentusers.
CLEAR wa_assortmentusersx.
ENDLOOP.
CALL FUNCTION 'BAPI_ASSORTMENT_MAINTAINDATA'
EXPORTING
assortment = wa_assortment
assortmentx = wa_assortmentx
IMPORTING
return = ld_return
TABLES
* MATERIALGROUP =
* MATERIALGROUPX =
description = it_description
descriptionx = it_descriptionx
descriptionx = it_descriptionx
assortmentusers = it_assortmentusers
assortmentusersx = it_assortmentusersx.
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
LOOP AT it_assortmentusers INTO wa_assortmentusers.
WRITE: ld_return-message,
wa_assortmentusers-customer_site, 'Добавлен в куб', wa_assortmentusers-assortment,
/.
ENDLOOP.
ENDIF.
venkateswaran_k
Active Contributor
0 Kudos

Yes, the description table is the key to change or delete

but i see two lines in descriptionx in BAPI

Is that typo error or actual

former_member797394
Participant
0 Kudos

venkateswaran.k,

this is a typo, in my program everything is written without duplications, i don't know why there is a typo here.

But still, this one did not work for me. 😞

venkateswaran_k
Active Contributor
0 Kudos

Hi

Just to confirm this BAPI works for the change/delete - please check as below

1. First remove the If condition and pass the function code 003 or 004 and see it has impact.

Just for your information - 003 - is for delete 004 - is for Change

2. Secondly in your if condition you stated LT ( Less than ). What if it is Less than or Equal to LE - Please handle this scenario also.

Regards,

Venkat

former_member797394
Participant
0 Kudos

venkateswaran.k,

I have managed to solve this issue with another way, finally. Thank you for your time and effort!

venkateswaran_k
Active Contributor

What was that.. Curious to know.

former_member797394
Participant
0 Kudos

venkateswaran.k,

I have used BAPI for creation and BDC for deletion.

I will post my code in a new comment, just in case.

That was full of fun.

Leave your feedback to my code, if something is wrong or If I should add something more.