FUNCTION Y_GL_M_RFC_UPDATE_TABLE.
*"----------------------------------------------------------------------
*"*"ローカルインタフェース:
*" IMPORTING
*" VALUE(I_TABNAME) TYPE TABNAME
*" VALUE(I_TBL_KEYFIELDS) TYPE STRINGVAL
*" VALUE(I_TBL_KEYVALUES) TYPE STRINGVAL
*" VALUE(I_UPD_FIELDS) TYPE STRINGVAL
*" VALUE(I_UPD_VALUES) TYPE STRINGVAL
*" EXPORTING
*" VALUE(RETURN) TYPE BAPIRET2
*"----------------------------------------------------------------------
DATA:
L_TBL_KEY_FLD TYPE TYP_I_COL,
L_TBL_KEY_VAL TYPE TYP_I_COL,
L_TBL_UPD_FLD TYPE TYP_I_COL,
L_TBL_UPD_VAL TYPE TYP_I_COL.
PERFORM CHECK_INPUT
USING
I_TABNAME
I_TBL_KEYFIELDS
I_TBL_KEYVALUES
I_UPD_FIELDS
I_UPD_VALUES
CHANGING
L_TBL_KEY_FLD
L_TBL_KEY_VAL
L_TBL_UPD_FLD
L_TBL_UPD_VAL
RETURN.
IF RETURN IS NOT INITIAL.
RETURN.
ENDIF.
PERFORM F_UPD_TBL_DATA
USING
I_TABNAME
L_TBL_KEY_FLD
L_TBL_KEY_VAL
L_TBL_UPD_FLD
L_TBL_UPD_VAL
CHANGING
RETURN.
ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Form RETUCHECK_INPUTRN_MSG.
*&---------------------------------------------------------------------*
* 入力パラメータチェックメッセージ編集
*----------------------------------------------------------------------*
FORM CHECK_INPUT USING VALUE(FU_TABLE_NAME) TYPE TABNAME
VALUE(FU_TBL_KEYFIELDS) TYPE STRINGVAL
VALUE(FU_TBL_KEYVALUES) TYPE STRINGVAL
VALUE(FU_UPD_FIELDS) TYPE STRINGVAL
VALUE(FU_UPD_VALUES) TYPE STRINGVAL
CHANGING VALUE(FC_TBL_KEY_FLD) TYPE TYP_I_COL
VALUE(FC_TBL_KEY_VAL) TYPE TYP_I_COL
VALUE(FC_TBL_UPD_FLD) TYPE TYP_I_COL
VALUE(FC_TBL_UPD_VAL) TYPE TYP_I_COL
VALUE(FC_RETURN) TYPE BAPIRET2.
DATA:
TBL_YSXF0001 TYPE STANDARD TABLE OF TYP_YSXF0001,
H_TBL_YSXF0001 TYPE TYP_YSXF0001,
RNG_DELETE TYPE RANGE OF DD03L-FIELDNAME,
H_RNG_DELETE LIKE LINE OF RNG_DELETE,
LV_INDEX_CNT TYPE I, "キー項目数
LV_FLD TYPE STRING, "更新列名
H_G_TBL_DD03L TYPE TYP_DD03L.
IF FU_TABLE_NAME IS INITIAL. "テーブル名未設定
PERFORM RETURN_MSG USING 'E' 'FPP' '002' 'I_TABNAME' '' '' '' FC_RETURN.
RETURN.
ENDIF.
IF FU_TABLE_NAME+0(1) <> CNS_Y AND " 1桁目'Z''Y'以外
FU_TABLE_NAME+0(1) <> CNS_Z.
PERFORM RETURN_MSG USING 'E' '54' '239' '' '' '' '' FC_RETURN.
RETURN.
ENDIF.
IF FU_TBL_KEYFIELDS IS INITIAL. "キー項目名ブランク
PERFORM RETURN_MSG USING 'E' 'FPP' '002' 'I_TBL_KEYFIELDS' '' '' '' FC_RETURN.
RETURN.
ENDIF.
IF FU_TBL_KEYVALUES IS INITIAL. "キー項目値ブランク
PERFORM RETURN_MSG USING 'E' 'FPP' '002' 'I_TBL_KEYVALUES' '' '' '' FC_RETURN.
RETURN.
ENDIF.
IF FU_UPD_FIELDS IS INITIAL. "更新項目名ブランク
PERFORM RETURN_MSG USING 'E' 'FPP' '002' 'I_UPD_FIELDS' '' '' '' FC_RETURN.
RETURN.
ENDIF.
IF FU_UPD_VALUES IS INITIAL. "更新項目値ブランク
PERFORM RETURN_MSG USING 'E' 'FPP' '002' 'I_UPD_VALUES' '' '' '' FC_RETURN.
RETURN.
ENDIF.
*->項目情報取得
SELECT
DD03L~POSITION "テーブル位置
DD03L~KEYFLAG "キー項目
DD03L~REFFIELD "参照項目
DD03L~DATATYPE "データ型
DD03L~LENG "文字数
DD03L~DECIMALS "小数点以下桁数
DD03L~FIELDNAME "項目名
DD03L~PRECFIELD "インクルード名
DD03L~REFTABLE "参照項目に対するテーブル
DD03L~MANDATORY "フラグ: 必須項目 (空白不可)
DD03L~CHECKTABLE "外部キーのチェックテーブル名
DD03L~NOTNULL "NOT NULL 必須
FROM
DD03L INNER JOIN DD02L
ON DD03L~TABNAME = DD02L~TABNAME
INTO TABLE G_TBL_DD03L
WHERE
DD03L~TABNAME = FU_TABLE_NAME AND
DD03L~AS4LOCAL = CNS_A AND
DD02L~AS4LOCAL = CNS_A AND
DD02L~TABCLASS = 'TRANSP'
ORDER BY
DD03L~POSITION ASCENDING.
IF SY-SUBRC <> 0.
PERFORM RETURN_MSG USING 'E' '38' '909' FU_TABLE_NAME '' '' '' FC_RETURN.
RETURN.
ENDIF.
SELECT FIELDNAME INTO TABLE TBL_YSXF0001
FROM DD03L
WHERE
TABNAME = CNS_YSXF0001 AND
AS4LOCAL = CNS_A.
* アドオンテーブル末尾項目取得
CLEAR RNG_DELETE.
LOOP AT TBL_YSXF0001 INTO H_TBL_YSXF0001.
IF H_TBL_YSXF0001-FIELDNAME = 'LOESCH'.
CONTINUE.
ENDIF.
MOVE 'I' TO H_RNG_DELETE-SIGN.
MOVE 'EQ' TO H_RNG_DELETE-OPTION.
MOVE H_TBL_YSXF0001-FIELDNAME TO H_RNG_DELETE-LOW.
APPEND H_RNG_DELETE TO RNG_DELETE.
ENDLOOP.
MOVE 'I' TO H_RNG_DELETE-SIGN.
MOVE 'EQ' TO H_RNG_DELETE-OPTION.
MOVE CNS_MANDT TO H_RNG_DELETE-LOW.
APPEND H_RNG_DELETE TO RNG_DELETE.
*->対象外データ削除
DELETE G_TBL_DD03L WHERE FIELDNAME IN RNG_DELETE.
DELETE G_TBL_DD03L WHERE FIELDNAME = CNS_INCLUDE.
*->パラメータ分割(キー項目名)
PERFORM F_SPLIT_TAB_TXT
USING
FU_TBL_KEYFIELDS
CHANGING
FC_TBL_KEY_FLD.
*->パラメータ分割(キー項目値)
PERFORM F_SPLIT_TAB_TXT
USING
FU_TBL_KEYVALUES
CHANGING
FC_TBL_KEY_VAL.
*->パラメータ分割(更新項目名)
PERFORM F_SPLIT_TAB_TXT
USING
FU_UPD_FIELDS
CHANGING
FC_TBL_UPD_FLD.
*->パラメータ分割(更新項目値)
PERFORM F_SPLIT_TAB_TXT
USING
FU_UPD_VALUES
CHANGING
FC_TBL_UPD_VAL.
LOOP AT FC_TBL_KEY_FLD INTO LV_FLD.
* キー項目値ブランク
IF LV_FLD IS INITIAL.
PERFORM RETURN_MSG USING 'E' 'OPS_SE_BPS_COMMON' '005' '' '' '' '' FC_RETURN.
CONCATENATE 'I_TBL_KEYFIELDS' FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
ENDLOOP.
LOOP AT FC_TBL_UPD_FLD INTO LV_FLD.
* 更新項目値ブランク
IF LV_FLD IS INITIAL.
PERFORM RETURN_MSG USING 'E' 'OPS_SE_BPS_COMMON' '005' '' '' '' '' FC_RETURN.
CONCATENATE 'I_UPD_FIELDS' FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
ENDLOOP.
IF LINES( FC_TBL_KEY_FLD ) <> LINES( FC_TBL_KEY_VAL ).
* キー項目名、キー項目値数一致しない
PERFORM RETURN_MSG USING 'E' 'VK' '410' 'I_TBL_KEYFIELDS' 'I_TBL_KEYVALUES' '' '' FC_RETURN.
RETURN.
ENDIF.
IF LINES( FC_TBL_UPD_FLD ) <> LINES( FC_TBL_UPD_VAL ).
* 更新項目名、更新項目値数一致しない
PERFORM RETURN_MSG USING 'E' 'VK' '410' 'I_UPD_FIELDS' 'I_UPD_VALUES' '' '' FC_RETURN.
RETURN.
ENDIF.
* 項目名不一致
CLEAR LV_INDEX_CNT.
LOOP AT G_TBL_DD03L INTO H_G_TBL_DD03L.
IF H_G_TBL_DD03L-KEYFLAG = ABAP_ON .
LV_INDEX_CNT = LV_INDEX_CNT + 1.
READ TABLE FC_TBL_KEY_FLD WITH KEY TABLE_LINE = H_G_TBL_DD03L-FIELDNAME TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
PERFORM RETURN_MSG USING 'E' '/BCV/FND' '006' FU_TABLE_NAME 'I_TBL_KEYFIELDS' '' '' FC_RETURN.
RETURN.
ENDIF.
ENDIF.
ENDLOOP.
* キー項目数不一致
IF LV_INDEX_CNT <> LINES( FC_TBL_KEY_FLD ).
PERFORM RETURN_MSG USING 'E' '/BCV/FND' '006' FU_TABLE_NAME 'I_TBL_KEYFIELDS' '' '' FC_RETURN.
RETURN.
ENDIF.
ENDFORM. "CHECK_INPUT
*&---------------------------------------------------------------------*
*& Form CREAT_UPD_DATA.
*&---------------------------------------------------------------------*
* 登録用データ作成
*----------------------------------------------------------------------*
FORM CREAT_UPD_DATA USING VALUE(FU_TABNAME) TYPE TABNAME
VALUE(FU_UPD_FLD) TYPE TYP_I_COL
VALUE(FU_UPD_VAL) TYPE TYP_I_COL
CHANGING VALUE(FU_ROW) TYPE ANY
VALUE(FC_RETURN) TYPE BAPIRET2.
DATA: H_G_TBL_DD03L TYPE TYP_DD03L,
LV_UPD_FLD TYPE STRING,
LV_UPD_VAL TYPE STRING,
LV_DATE TYPE SY-DATUM,
LV_TIMES TYPE SY-UZEIT,
LV_INDEX TYPE SY-TABIX,
LV_ERR_CHAR(1024) TYPE C,
LV_HTYPE TYPE DD01V-DATATYPE,
LV_WAERS_INDEX TYPE SY-TABIX,
LV_UPD_WAERS TYPE TCURC-WAERS,
LV_UPD_VAL_CHK TYPE CHAR80,
LV_UPD_EXTERNAL TYPE BAPICURR-BAPICURR,
LV_UPD_VAL_OK TYPE STRING,
LV_DECIMALPART TYPE CHAR20,
LV_DEC_LENI TYPE I,
LV_DEC_LEN TYPE CHAR02,
L_RETURN2 TYPE BAPIRETURN.
FIELD-SYMBOLS:
<FS_FIELD> TYPE ANY.
LOOP AT FU_UPD_FLD INTO LV_UPD_FLD.
MOVE SY-TABIX TO LV_INDEX.
READ TABLE FU_UPD_VAL INTO LV_UPD_VAL INDEX LV_INDEX.
MOVE LV_UPD_VAL TO LV_ERR_CHAR. "エラーメッセージ表示用
READ TABLE G_TBL_DD03L INTO H_G_TBL_DD03L
WITH KEY FIELDNAME = LV_UPD_FLD
KEYFLAG = SPACE.
CASE H_G_TBL_DD03L-DATATYPE.
WHEN CNS_NUMC.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = LV_UPD_VAL
IMPORTING
HTYPE = LV_HTYPE.
IF LV_HTYPE <> CNS_NUMC.
PERFORM RETURN_MSG USING 'E' '56' '083' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
* 桁数チェックを行う
IF STRLEN( LV_UPD_VAL ) > H_G_TBL_DD03L-LENG.
PERFORM RETURN_MSG USING 'E' 'KG' '618' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
MOVE LV_UPD_VAL TO LV_UPD_VAL_OK.
WHEN: CNS_CURR OR CNS_QUAN OR CNS_DEC.
CALL FUNCTION 'CATS_NUMERIC_INPUT_CHECK'
EXPORTING
INPUT = LV_UPD_VAL
IMPORTING
OUTPUT = LV_UPD_VAL_CHK
EXCEPTIONS
NO_NUMERIC = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
PERFORM RETURN_MSG USING 'E' '56' '083' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
IF H_G_TBL_DD03L-DATATYPE = CNS_CURR.
"金額内部値変換
IF H_G_TBL_DD03L-REFTABLE <> FU_TABNAME.
* 項目情報のREFTABLEの値が、パラメータ「テーブル名」と等しくない場合エラーとする
PERFORM RETURN_MSG USING 'E' 'FDT_CORE' '409' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
* 更新項目に通貨指定あるか
READ TABLE FU_UPD_FLD TRANSPORTING NO FIELDS
WITH KEY TABLE_LINE = H_G_TBL_DD03L-REFFIELD.
IF SY-SUBRC = 0.
MOVE SY-TABIX TO LV_WAERS_INDEX.
READ TABLE FU_UPD_VAL INTO LV_UPD_WAERS INDEX LV_WAERS_INDEX.
ELSE.
ASSIGN COMPONENT H_G_TBL_DD03L-REFFIELD
OF STRUCTURE FU_ROW TO <FS_FIELD>.
MOVE <FS_FIELD> TO LV_UPD_WAERS.
ENDIF.
TRY.
MOVE LV_UPD_VAL_CHK TO LV_UPD_EXTERNAL.
CATCH CX_SY_CONVERSION_NO_NUMBER CX_SY_CONVERSION_OVERFLOW.
PERFORM RETURN_MSG USING 'E' 'KG' '618' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDTRY.
* 金額を内部値変換
CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_INTERNAL'
EXPORTING
CURRENCY = LV_UPD_WAERS
AMOUNT_EXTERNAL = LV_UPD_EXTERNAL
MAX_NUMBER_OF_DIGITS = 18
IMPORTING
AMOUNT_INTERNAL = LV_UPD_EXTERNAL
RETURN = L_RETURN2.
IF L_RETURN2 IS NOT INITIAL.
CONCATENATE LV_UPD_VAL_CHK LV_UPD_WAERS INTO LV_ERR_CHAR.
PERFORM RETURN_MSG USING 'E' 'YXF01' '246' LV_ERR_CHAR '' '' '' FC_RETURN.
RETURN.
ENDIF.
MOVE LV_UPD_EXTERNAL TO LV_UPD_VAL_OK.
ELSE.
MOVE LV_UPD_VAL TO LV_UPD_VAL_OK.
ENDIF.
IF ABS( LV_UPD_VAL_OK ) >= 10 ** ( H_G_TBL_DD03L-LENG - H_G_TBL_DD03L-DECIMALS ).
"桁溢れ 例:QUAN 長さ 10 小数点 3 格納できる数字 9999999.999
PERFORM RETURN_MSG USING 'E' 'KG' '618' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
* 小数部分求める(例:15.437 小数部分0.437 小数部分桁数 = 5-2 )
LV_DECIMALPART = ABS( FRAC( LV_UPD_VAL_OK ) ).
CONDENSE LV_DECIMALPART.
LV_DEC_LENI = STRLEN( LV_DECIMALPART ) - 2.
IF LV_DEC_LENI > H_G_TBL_DD03L-DECIMALS.
MOVE H_G_TBL_DD03L-DECIMALS TO LV_DEC_LENI.
MOVE LV_DEC_LENI TO LV_DEC_LEN.
PERFORM RETURN_MSG USING 'E' 'DB' '739' LV_DEC_LEN '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
WHEN CNS_DATE.
* 日付項目チェック
MOVE LV_UPD_VAL TO LV_DATE.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = LV_DATE
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0 OR STRLEN( LV_UPD_VAL ) > H_G_TBL_DD03L-LENG .
PERFORM RETURN_MSG USING 'E' 'S5' '006' LV_ERR_CHAR '' '' '' FC_RETURN.
RETURN.
ENDIF.
MOVE LV_DATE TO LV_UPD_VAL_OK.
WHEN CNS_TIMS.
* 時間項目チェック
MOVE LV_UPD_VAL TO LV_TIMES.
CALL FUNCTION 'TIME_CHECK_PLAUSIBILITY'
EXPORTING
TIME = LV_TIMES
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0 OR STRLEN( LV_UPD_VAL ) > H_G_TBL_DD03L-LENG.
PERFORM RETURN_MSG USING 'E' 'S5' '007' LV_ERR_CHAR '' '' '' FC_RETURN.
RETURN.
ENDIF.
MOVE LV_TIMES TO LV_UPD_VAL_OK.
WHEN OTHERS.
MOVE LV_UPD_VAL TO LV_UPD_VAL_OK.
ENDCASE.
ASSIGN COMPONENT LV_UPD_FLD OF STRUCTURE FU_ROW TO <FS_FIELD>.
TRY.
MOVE LV_UPD_VAL_OK TO <FS_FIELD>.
CATCH CX_SY_CONVERSION_NO_NUMBER.
PERFORM RETURN_MSG USING 'E' '56' '083' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
CATCH CX_SY_CONVERSION_OVERFLOW.
PERFORM RETURN_MSG USING 'E' 'KG' '618' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
CATCH CX_SY_CONVERSION_ERROR.
* CX_SY_CONVERSION_NO_NUMBER CX_SY_CONVERSION_OVERFLOWは実際CX_SY_CONVERSION_ERRORに従属する
PERFORM RETURN_MSG USING 'E' 'FKKBI_INTERNAL' '056' '' '' '' '' FC_RETURN.
CONCATENATE LV_UPD_FLD FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDTRY.
ENDLOOP.
ENDFORM. "CREAT_TABLE
*&---------------------------------------------------------------------*
*& Form F_UPD_TBL_DATA
*&---------------------------------------------------------------------*
* テーブル更新処理
*----------------------------------------------------------------------*
FORM F_UPD_TBL_DATA USING VALUE(FU_TABNAME) TYPE TABNAME
VALUE(FU_TBL_KEY_FLD) TYPE TYP_I_COL
VALUE(FU_TBL_KEY_VAL) TYPE TYP_I_COL
VALUE(FU_UPD_FLD) TYPE TYP_I_COL
VALUE(FU_UPD_VAL) TYPE TYP_I_COL
CHANGING VALUE(FC_RETURN) TYPE BAPIRET2.
DATA:
LV_INDEX TYPE SY-TABIX,
LV_KEY_VAL TYPE STRING,
L_KEY TYPE RSTABLE-VARKEY,
H_G_TBL_DD03L TYPE TYP_DD03L,
L_H_TBL TYPE REF TO DATA,
LV_UPD_FLD TYPE STRING,
LV_UPD_VAL TYPE STRING,
LV_FLD_NM TYPE DD03L-FIELDNAME, "列名
L_TBL_EXT_ID TYPE OLR3_R3_TT_ID_SPLIT, "存在チェック用テーブル
L_H_TBL_EXT_ID TYPE OLR3_R3_TS_ID_SPLIT, "存在チェック用テーブルの行
L_RETURN TYPE BAPIRETURN1,
L_TBL_WHERE TYPE TABLE OF EDPLINE, "WHERE条件
L_H_TBL_WHERE TYPE EDPLINE, "WHERE条件の行
LV_AND_FLG TYPE CHAR01, "AND
LV_UPD_FLG TYPE CHAR01. "更新成功フラグ
FIELD-SYMBOLS:
<FS_ROW> TYPE ANY,
<FS_FIELD> TYPE ANY.
CLEAR:
L_KEY,
L_TBL_WHERE,
LV_AND_FLG.
* ロックキーと検索用WHERE条件作成
LOOP AT G_TBL_DD03L INTO H_G_TBL_DD03L
WHERE KEYFLAG IS NOT INITIAL.
* インポートパラメータキーの順番と定義必ず一致ではないため
READ TABLE FU_TBL_KEY_FLD
WITH KEY TABLE_LINE = H_G_TBL_DD03L-FIELDNAME
TRANSPORTING NO FIELDS.
*
MOVE SY-TABIX TO LV_INDEX.
READ TABLE FU_TBL_KEY_VAL INTO LV_KEY_VAL INDEX LV_INDEX.
* テーブルロックキー作成する
CONCATENATE L_KEY LV_KEY_VAL INTO L_KEY.
* 1行目 AND必要ない、2行目から AND付ける必要
IF LV_AND_FLG IS NOT INITIAL.
APPEND 'AND' TO L_TBL_WHERE.
ENDIF.
CONCATENATE H_G_TBL_DD03L-FIELDNAME ' = ''' LV_KEY_VAL '''' INTO L_H_TBL_WHERE.
APPEND L_H_TBL_WHERE TO L_TBL_WHERE.
LV_AND_FLG = ABAP_ON.
ENDLOOP.
LOOP AT FU_UPD_FLD INTO LV_UPD_FLD.
MOVE SY-TABIX TO LV_INDEX.
READ TABLE FU_UPD_VAL INTO LV_UPD_VAL INDEX LV_INDEX.
MOVE LV_UPD_FLD TO LV_FLD_NM.
READ TABLE G_TBL_DD03L INTO H_G_TBL_DD03L
WITH KEY FIELDNAME = LV_UPD_FLD
KEYFLAG = SPACE.
IF SY-SUBRC <> 0.
* 項目 & は (有効バージョンの) テーブル &2 に存在しません
PERFORM RETURN_MSG USING 'E' '37' '526' LV_FLD_NM FU_TABNAME '' '' FC_RETURN.
RETURN.
ENDIF.
* 必須チェック
IF H_G_TBL_DD03L-MANDATORY = ABAP_ON AND
LV_UPD_VAL IS INITIAL.
* 必須項目 '&1' に入力してください
PERFORM RETURN_MSG USING 'E' '/BCV/CFG' '028' LV_FLD_NM '' '' '' FC_RETURN.
RETURN.
ENDIF.
IF H_G_TBL_DD03L-NOTNULL = ABAP_ON AND
LV_UPD_VAL IS INITIAL.
* 入力項目には Null 値が含まれています 入力項目に値を入力してください
PERFORM RETURN_MSG USING 'E' 'OPS_SE_BPS_COMMON' '005' '' '' '' '' FC_RETURN.
CONCATENATE LV_FLD_NM FC_RETURN-MESSAGE INTO FC_RETURN-MESSAGE.
RETURN.
ENDIF.
IF H_G_TBL_DD03L-CHECKTABLE IS NOT INITIAL AND
H_G_TBL_DD03L-CHECKTABLE <> CNS_ASTERISK.
* 存在チェック
CLEAR:
L_TBL_EXT_ID,
L_H_TBL_EXT_ID.
MOVE LV_FLD_NM TO L_H_TBL_EXT_ID-OLR3_TAB_FIELD.
MOVE LV_UPD_VAL TO L_H_TBL_EXT_ID-OLR3_TAB_VALUE.
APPEND L_H_TBL_EXT_ID TO L_TBL_EXT_ID.
CALL METHOD CL_R3_OLR3_METHODS=>CHECK_EXISTENCE
EXPORTING
IT_EXT_ID = L_TBL_EXT_ID
IV_TABNAME = H_G_TBL_DD03L-CHECKTABLE
IMPORTING
EV_RETURN = L_RETURN.
IF L_RETURN-TYPE = CNS_TYP_E.
PERFORM RETURN_MSG USING 'E' '/SAPNEA/J_SC' '084' H_G_TBL_DD03L-CHECKTABLE L_H_TBL_EXT_ID-OLR3_TAB_VALUE '' '' FC_RETURN.
RETURN.
ENDIF.
ENDIF.
ENDLOOP.
CALL FUNCTION 'ENQUEUE_E_TABLEE'
EXPORTING
TABNAME = FU_TABNAME
VARKEY = L_KEY
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* テーブル &1 をロックできませんでした
PERFORM RETURN_MSG USING 'E' 'BV' '019' FU_TABNAME '' '' '' FC_RETURN.
RETURN.
ENDIF.
CREATE DATA L_H_TBL TYPE (FU_TABNAME).
ASSIGN L_H_TBL->* TO <FS_ROW>.
SELECT SINGLE FOR UPDATE *
FROM (FU_TABNAME)
INTO <FS_ROW>
WHERE (L_TBL_WHERE).
CLEAR LV_UPD_FLG.
IF SY-SUBRC <> 0.
* 指定キーの更新データがありません。
PERFORM RETURN_MSG
USING 'E' 'PPETICMP' '009' TEXT-T02 '' '' '' FC_RETURN.
ELSE.
* 更新項目の値を設定
PERFORM CREAT_UPD_DATA
USING
FU_TABNAME
FU_UPD_FLD
FU_UPD_VAL
CHANGING
<FS_ROW>
FC_RETURN.
IF FC_RETURN IS INITIAL.
* 更新日付、時間、更新者、更新プログラム設定
ASSIGN COMPONENT 'YEUPDAT' OF STRUCTURE <FS_ROW> TO <FS_FIELD>.
IF SY-SUBRC = 0.
MOVE SY-DATUM TO <FS_FIELD>.
ENDIF.
ASSIGN COMPONENT 'YEUPTIM' OF STRUCTURE <FS_ROW> TO <FS_FIELD>.
IF SY-SUBRC = 0.
MOVE SY-UZEIT TO <FS_FIELD>.
ENDIF.
ASSIGN COMPONENT 'YEUPUNM' OF STRUCTURE <FS_ROW> TO <FS_FIELD>.
IF SY-SUBRC = 0.
MOVE SY-UNAME TO <FS_FIELD>.
ENDIF.
ASSIGN COMPONENT 'YEUPTCD' OF STRUCTURE <FS_ROW> TO <FS_FIELD>.
IF SY-SUBRC = 0.
MOVE 'Y_GL_M_RFC_UPDATE_TABLE' TO <FS_FIELD>.
ENDIF.
TRY.
UPDATE (FU_TABNAME) FROM <FS_ROW>.
* 更新成功フラグを設定.
MOVE ABAP_ON TO LV_UPD_FLG.
CATCH CX_SY_OPEN_SQL_DB.
CLEAR LV_UPD_FLG.
ENDTRY.
IF LV_UPD_FLG IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = ABAP_ON.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
PERFORM RETURN_MSG
USING 'E' '1I' '888' FU_TABNAME '' '' '' FC_RETURN.
ENDIF.
ENDIF.
ENDIF.
CALL FUNCTION 'DEQUEUE_ALL'
EXPORTING
_SYNCHRON = ABAP_ON.
IF LV_UPD_FLG IS NOT INITIAL.
PERFORM RETURN_MSG
USING 'S' '1M' '804' FU_TABNAME TEXT-T01 '' '' FC_RETURN.
ENDIF.
ENDFORM. "F_UPD_TBL_DATA
*&---------------------------------------------------------------------*
*& Form F_SPLIT_TAB_TXT
*&---------------------------------------------------------------------*
* TABテキスト分割して値を内部テーブルに格納する
*----------------------------------------------------------------------*
FORM F_SPLIT_TAB_TXT USING VALUE(FU_TXT) TYPE STRINGVAL
CHANGING VALUE(FC_COLS) TYPE TYP_I_COL.
* TAB分割後の値を内部テーブルに格納する
SPLIT FU_TXT AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO TABLE FC_COLS.
ENDFORM. "F_SPLIT_TAB_TXT
*&---------------------------------------------------------------------*
*& Form RETURN_MSG.
*&---------------------------------------------------------------------*
* メッセージ編集
*----------------------------------------------------------------------*
FORM RETURN_MSG USING
FU_TYPE TYPE BAPIRETURN-TYPE "メッセージタイプ.
FU_CL TYPE SY-MSGID "メッセージID
FU_NUMBER TYPE SY-MSGNO "メッセージ番号
FU_PAR1 TYPE C "TEXT.
FU_PAR2 TYPE C "TEXT.
FU_PAR3 TYPE C "TEXT.
FU_PAR4 TYPE C "TEXT.
FU_RESULT TYPE BAPIRET2. "処理結果テーブル
*----------------------------------------------------------------------*
DATA:L_MSGV1 TYPE SY-MSGV1,
L_MSGV2 TYPE SY-MSGV2,
L_MSGV3 TYPE SY-MSGV3,
L_MSGV4 TYPE SY-MSGV4.
*----------------------------------------------------------------------*
MOVE:FU_PAR1 TO L_MSGV1,
FU_PAR2 TO L_MSGV2,
FU_PAR3 TO L_MSGV3,
FU_PAR4 TO L_MSGV4.
CALL FUNCTION 'BALW_BAPIRETURN_GET2'
EXPORTING
TYPE = FU_TYPE
CL = FU_CL
NUMBER = FU_NUMBER
PAR1 = L_MSGV1
PAR2 = L_MSGV2
PAR3 = L_MSGV3
PAR4 = L_MSGV4
IMPORTING
RETURN = FU_RESULT.
ENDFORM. "RETURN_MSG
2019年9月4日星期三
订阅:
博文评论 (Atom)
Customer Characteristic
Characteristic Descriptions are stored in the table - CABNT - Language - SPRAS - Characteristic description - ATBEZ Characteristic Values ...
-
REPORT ZBPADD2 . DATA : L_PARTN_CAT TYPE BAPIBUS1006_HEAD - PARTN_CAT , LS_CENTRAL TYPE BAPIBUS1006_CENTRAL , ...
-
HEADER: ADD Customer Fields to structure of IMKPF and BAPI_TE_XMKPF. Items: ADD Customer Fields to structure of IMSEG and BAPI_TE_XMSEG....
-
FUNCTION:SD_SALESDOCUMENT_CREATE Append fiels to Structure below. BAPE_VBAP BAPE_VBAPX VBAPKOZ VBAPKOZX No need to append fields to Struc...
没有评论:
发表评论