Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

This page is particularly helpful for technical consultants working for SAP-retail and want to create characteristic values for a characteristic as we see in transaction WRFCHVAL

Even if the function module to be used for this is not yet released by SAP but as of now , i could find only this way to create / assign characteristic values using Function Module.

Overview

In this page ,we are considering that data is coming through IDOC and we have to create create/ assign characteristic values based on IDOC data .

Retrieve Idocs

  1. First , we will retrieve the idocs from table EDIDC based on Idoc Status =64 and ( other statuses as per Business functionality)

  2. Next we read the idoc segments from table EDID4 for all the document numbers retrieved form above step1.

  3. Based on  all existing characteristics retrived form IDOC , get corresponding Characteristic type from table WRF_CHARVAL_HEAD.

  4. Check if Characteristic Value already created or not for the characteristic using table WRF_CHARVAL:

    1. If Characteristic Value already created then we have to first get all existing characteristic value details from table WRF_CHARVAL and then overwrite/update with the new values passed from IDOC  .

      ls_charval_upd-atinn = atinn < Char. ref No>
      ls_charval_upd-atwrt = <Idoc_Segment_W1RFOBJ-obj_name>.
      ls_charval_upd-srtpo = <Sort Position srtpo>.
      ls_charval_upd-cstfld01 = Idoc_Segment_W1RFOBJ-cstfld01.
      ls_charval_upd-cstfld02 = Idoc_Segment_W1RFOBJ-cstfld02.
      ls_charval_upd-cstfld03 = Idoc_Segment_W1RFOBJ-cstfld03.
      ls_charval_upd-cstfld04 = Idoc_Segment_W1RFOBJ-cstfld04.
      ls_charval_upd-cstfld05 = Idoc_Segment_W1RFOBJ-cstfld05.
      ls_charval_upd-cstfld06 = Idoc_Segment_W1RFOBJ-cstfld06.
      ls_charval_upd-cstfld07 = Idoc_Segment_W1RFOBJ-cstfld07.
      ls_charval_upd-cstfld08 = Idoc_Segment_W1RFOBJ-cstfld08.
      ls_charval_upd-cstfld09 = Idoc_Segment_W1RFOBJ-cstfld09.
      ls_charval_upd-cstfld10 = Idoc_Segment_W1RFOBJ-cstfld10.
      ls_charval_upd-ernam = sy-uname.
      ls_charval_upd-erdat = sy-datum.
      ls_charval_upd-aenam = sy-uname.
      ls_charval_upd-aedat = sy-datum.

      APPEND ls_charval_upd TO t_charval_upd.

    2. If this characteristic values not yet exist  then we have to insert it. Sort all the values found from step a and increment it by one .This will be the sort position for the new value to be assigned .

      ls_charval_ins-atinn = atinn <Characteritic Reference Number>.
      ls_charval_ins-atwrt = Idoc_segment_w1rfobj-obj_name.
      ls_charval_ins-cstfld01 = Idoc_segment_w1rfobj-cstfld01.
      ls_charval_ins-cstfld02 = Idoc_segment_w1rfobj-cstfld02.
      ls_charval_ins-cstfld03 = Idoc_segment_w1rfobj-cstfld03.
      ls_charval_ins-cstfld04 = Idoc_segment_w1rfobj-cstfld04.
      ls_charval_ins-cstfld05 = Idoc_segment_w1rfobj-cstfld05.
      ls_charval_ins-cstfld06 = Idoc_segment_w1rfobj-cstfld06.
      ls_charval_ins-cstfld07 = Idoc_segment_w1rfobj-cstfld07.
      ls_charval_ins-cstfld08 = Idoc_segment_w1rfobj-cstfld08.
      ls_charval_ins-cstfld09 = Idoc_segment_w1rfobj-cstfld09.
      ls_charval_ins-cstfld10 = Idoc_segment_w1rfobj-cstfld10.
      ls_charval_ins-srtpo = <Sort Position>
      ls_charval_ins-ernam = sy-uname.
      ls_charval_ins-erdat = sy-datum.
      ls_charval_ins-aenam = sy-uname.
      ls_charval_ins-aedat = sy-datum.



                     APPEND ls_charval_ins TO t_charval_ins.


  5. Call  function CONVERSION_EXIT_ALPHA_INPUT before passing Object reference number to below function module  WRF_CHARVAL_SAVE_DATABASE

  6.   CALL FUNCTION 'WRF_CHARVAL_SAVE_DATABASE'
                 EXPORTING
                   atinn          lv_atinn
                   atnam          lv_atnam
                   chartyp        lv_chartype
                   checkopt       ygzzcl_constants=>c_checkopt_e    "'E'
                 TABLES
                   t_charval_ins  i_gt_t_charval_ins
                   t_charval_upd  i_gt_t_charval_upd


                   return         i_gt_return
                 EXCEPTIONS
                   head_error     1
                   OTHERS         2.
               IF sy-subrc <> 0.

    IF sy-subrc <> 0.  "Insert error

             CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    ELSE.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

    Endif.
  • No labels