Simple ABAP - Change allowed values in a characteristic by BAPI_CHARACT_CHANGE

本文介绍如何使用BAPI_CHARACT_CHANGE函数添加允许的字符值到特征中,包括设置详细信息、描述、数值、日期、时间、货币格式等。

Simple report to add an allowed (CHAR) value to a characteristic using the BAPI method BAPI_CHARACT_CHANGE

*&---------------------------------------------------------------------*
*& Report  ZSDN_CHARVALUE_ADD
*&
*&---------------------------------------------------------------------*
*& Simple report to add an allowed (CHAR) value to a characteristic
*& using method BAPI_CHARACT_CHANGE
*&---------------------------------------------------------------------*
 
REPORT  zsdn_charvalue_add LINE-SIZE 255.
 
DATA:   return               LIKE bapiret2 OCCURS 0,
        wa_ret               LIKE bapiret2,
        charactname          LIKE bapicharactkey-charactname,
        charactdetailnew     LIKE bapicharactdetail OCCURS 0,
        char_detail          LIKE bapicharactdetail,
        charactdescrnew      LIKE bapicharactdescr OCCURS 0,
        char_descr_new       LIKE bapicharactdescr,
        charactvaluescharnew LIKE bapicharactvalueschar OCCURS 0,
        char_val_char        LIKE bapicharactvalueschar,
        charactvaluesnumnew  LIKE bapicharactvaluesnum OCCURS 0,
        char_val_num         LIKE bapicharactvaluesnum,
        charactvaluescurr    LIKE bapicharactvaluescurr OCCURS 0,
        charactvaluesdescrnew   LIKE bapicharactvaluesdescr OCCURS 0,
        charactvaluesdescr   LIKE bapicharactvaluesdescr ,
        charactreferences    LIKE bapicharactreferences OCCURS 0,
        charactrestrictions  LIKE bapicharactrestrictions OCCURS 0.
 
PARAMETERS: charname TYPE rctav-atnam OBLIGATORY MATCHCODE OBJECT merk.
 
charactname = charname.
CALL FUNCTION 'BAPI_CHARACT_GETDETAIL'
  EXPORTING
    charactname         = charactname
  IMPORTING
    charactdetail       = char_detail
  TABLES
    charactdescr        = charactdescrnew
    charactvaluesnum    = charactvaluesnumnew
    charactvalueschar   = charactvaluescharnew
    charactvaluescurr   = charactvaluescurr
    charactvaluesdescr  = charactvaluesdescrnew
    charactreferences   = charactreferences
    charactrestrictions = charactrestrictions
    return              return.
 
*Character format (CHAR): for characteristic values that consist of a character string
*Numeric format (NUM): for numeric characteristic values
*Date format (DATE): for characteristic values that represent a date
*Time format (TIME): for characteristic values that represent a time
*Currency format (CURR): for characteristic values that are entered in a currency
APPEND char_detail TO charactdetailnew.
 
CASE char_detail-data_type.
  WHEN 'CHAR'.
 
    char_val_char-value_char = 'SDN_TEST'.
    APPEND char_val_char TO charactvaluescharnew.
 
    charactvaluesdescr-language_int            = sy-langu.
    WRITE  charactvaluesdescr-language_int  TO charactvaluesdescr-language_iso.
    charactvaluesdescr-value_char              =  'SDN_TEST'.
    charactvaluesdescr-description         = 'Simple SDN Test'.
    APPEND charactvaluesdescr TO charactvaluesdescrnew.
 
    CALL FUNCTION 'BAPI_CHARACT_CHANGE'
            EXPORTING
              charactname           = charactname
            TABLES
              charactdetailnew      = charactdetailnew
              charactdescrnew       = charactdescrnew
*             charactvaluesnumnew   = charactvaluesnumnew
              charactvaluescharnew  = charactvaluescharnew
*             CHARACTVALUESCURRNEW
              charactvaluesdescrnew = charactvaluesdescrnew
*             CHARACTREFERENCESNEW
*             CHARACTRESTRICTIONSNEW
              return                return.
 
    LOOP AT return INTO wa_ret WHERE type = 'A' OR type = 'E'.
      EXIT.
    ENDLOOP.
    IF sy-subrc <> 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDIF.
 
    LOOP AT return INTO wa_ret.
      WRITE:/ wa_ret-message.
    ENDLOOP.
 
  WHEN OTHERS.
ENDCASE.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值