SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_CHARACT_CHANGE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat May 10, 2008 7:16 pm    Post subject: BAPI_CHARACT_CHANGE Reply with quote

BAPI_CHARACT_CHANGE - Change Characteristic

Code:
*&---------------------------------------------------------------------*
*&      Form  create_characteristics
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM create_characteristics.
*-The following two tables are of main concern for characteristics
*1. t_charactdetail -> Contains the basic information
*2. t_charact_dwnld -> Holds the descriptions/values, etc..

  DATA : tl_charactdetail TYPE TABLE OF bapicharactdetail,
  tl_charactdescr TYPE TABLE OF bapicharactdescr,
  tl_charactvaluesnum TYPE TABLE OF bapicharactvaluesnum,
  tl_charactvalueschar TYPE TABLE OF bapicharactvalueschar,
  tl_charactvaluesdescr TYPE TABLE OF bapicharactvaluesdescr.

  DATA : wal_charactdescr TYPE bapicharactdescr,
  wal_charactvalueschar TYPE bapicharactvalueschar,
  wal_charactvaluesdescr TYPE bapicharactvaluesdescr,
  wal_charactvaluesnum TYPE bapicharactvaluesnum.

  DATA : wl_count TYPE i,
  wl_err_flg TYPE c.

  FIELD-SYMBOLS : <charactdetail> LIKE bapicharactdetail,
  <charact_dwnld> LIKE LINE OF t_charact_dwnld.

  LOOP AT t_charactdetail ASSIGNING <charactdetail>.
    REFRESH : t_return2, tl_charactdescr, tl_charactvalueschar,
    tl_charactvaluesnum, tl_charactvaluesdescr,
    tl_charactdetail.
    CLEAR : wl_err_flg.
    wl_count = wl_count + 1.
*   SET zebra
    perform set_zebra using wl_count.

    CALL FUNCTION 'BAPI_CHARACT_EXISTENCECHECK'
      EXPORTING
        charactname = <charactdetail>-charact_name
      TABLES
        return      = t_return2.

    READ TABLE t_return2 ASSIGNING <bapiret2> INDEX 1.
    IF sy-subrc EQ 0 AND <bapiret2>-type = 'I' AND
    <bapiret2>-id = 'C1' AND <bapiret2>-number = '003'.
    ELSEIF p_update IS INITIAL.
      WRITE :/ <bapiret2>.
      CONTINUE.
    ENDIF.
    LOOP AT t_charact_dwnld ASSIGNING <charact_dwnld>
    WHERE name_char = <charactdetail>-charact_name.
      CLEAR : wal_charactdescr, wal_charactvalueschar,
      wal_charactvaluesdescr, wal_charactvaluesnum.
      MOVE-CORRESPONDING <charact_dwnld> TO : wal_charactdescr,
      wal_charactvalueschar.
      wal_charactvaluesdescr-language_int =
      <charact_dwnld>-language_int_descr.
      wal_charactvaluesdescr-language_iso =
      <charact_dwnld>-language_iso_descr.
      wal_charactvaluesdescr-value_char =
      <charact_dwnld>-value_char_descr.
      wal_charactvaluesdescr-description =
      <charact_dwnld>-description_descr.
      wal_charactvaluesnum-value_from = <charact_dwnld>-value_from.
      wal_charactvaluesnum-value_to = <charact_dwnld>-value_to.
      wal_charactvaluesnum-value_relation
      = <charact_dwnld>-value_relation.
      wal_charactvaluesnum-unit_from = <charact_dwnld>-unit_from.
      wal_charactvaluesnum-unit_to = <charact_dwnld>-unit_to.
      wal_charactvaluesnum-unit_from_iso
      = <charact_dwnld>-unit_from_iso.
      wal_charactvaluesnum-unit_to_iso = <charact_dwnld>-unit_to_iso.
      wal_charactvaluesnum-default_value
      = <charact_dwnld>-default_value_num.
      IF NOT wal_charactdescr IS INITIAL.
        APPEND wal_charactdescr TO tl_charactdescr.
      ENDIF.
      IF NOT wal_charactvalueschar IS INITIAL.
        APPEND wal_charactvalueschar TO tl_charactvalueschar.
      ENDIF.
      IF NOT wal_charactvaluesdescr IS INITIAL.
        APPEND wal_charactvaluesdescr TO tl_charactvaluesdescr.
      ENDIF.
      IF NOT wal_charactvaluesnum IS INITIAL.
        APPEND wal_charactvaluesnum TO tl_charactvaluesnum.
      ENDIF.
    ENDLOOP.
    REFRESH t_return2.
    CHECK ( NOT tl_charactvalueschar[] IS INITIAL ) OR
    ( NOT tl_charactdescr[] IS INITIAL ).
    CASE p_update.
      WHEN space.
        CALL FUNCTION 'BAPI_CHARACT_CREATE'
          EXPORTING
            charactdetail      = <charactdetail>
          TABLES
            charactdescr       = tl_charactdescr
            charactvaluesnum   = tl_charactvaluesnum
            charactvalueschar  = tl_charactvalueschar
            charactvaluesdescr = tl_charactvaluesdescr
            return             = t_return2.
      WHEN OTHERS.
        APPEND <charactdetail> TO tl_charactdetail.
        CALL FUNCTION 'BAPI_CHARACT_CHANGE'
          EXPORTING
            charactname           = <charactdetail>-charact_name
          TABLES
            charactdetailnew      = tl_charactdetail
            charactdescrnew       = tl_charactdescr
            charactvaluesnumnew   = tl_charactvaluesnum
            charactvaluescharnew  = tl_charactvalueschar
            charactvaluesdescrnew = tl_charactvaluesdescr
            return                = t_return2.
    ENDCASE.
    LOOP AT t_return2 ASSIGNING <bapiret2>.
      IF <bapiret2>-type = 'E'.
        FORMAT RESET.
        FORMAT COLOR COL_NEGATIVE INVERSE ON.
        wl_err_flg = 'X'.
      ELSE.
        PERFORM set_zebra USING wl_count.
      ENDIF.
      WRITE :/ <bapiret2>.
    ENDLOOP.
    CHECK wl_err_flg IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
  ENDLOOP.

ENDFORM. " create_characteristics
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.