FORM frm_edit_batch TABLES pt_field STRUCTURE dfies
USING ps_batch TYPE ty_batch
CHANGING ps_rturn TYPE bapiret2.
DATA : lv_key TYPE bapi1003_key-object,
lv_table TYPE bapi1003_key-objecttable VALUE 'MCH1',
lv_class TYPE bapi1003_key-classnum VALUE 'Z_CLASS_BATCH',
lv_class_type TYPE bapi1003_key-classtype VALUE '023',
lv_status TYPE bapi1003_key-status,
*--------------------TUS-CHARG-BEGIN---------------------------------*
lt_alloc_curr TYPE TABLE OF zbapi1003_alloc_values_curr,
lt_alloc_num TYPE TABLE OF zbapi1003_alloc_values_num,
lt_alloc_char TYPE TABLE OF zbapi1003_alloc_values_char,
*--------------------TUS-CHARG-END-----------------------------------*
lt_return TYPE TABLE OF bapiret2,
ls_return TYPE bapiret2.
DATA:ls_field TYPE dfies,
lv_field(100) TYPE c.
*--------------------TUS-CHARG-BEGIN---------------------------------*
FIELD-SYMBOLS:
TYPE zbapi1003_alloc_values_curr,
TYPE zbapi1003_alloc_values_char,
TYPE zbapi1003_alloc_values_num,
.
*--------------------TUS-CHARG-END-----------------------------------*
REFRESH:lt_alloc_curr,lt_return,lt_alloc_num,lt_alloc_char.
CLEAR:lv_key,lv_status,ls_return.
lv_key+0(18) = ps_batch-matnr.
lv_key+18(10) = ps_batch-charg.
*--------------------TUS-CHARG-BEGIN---------------------------------*
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = lv_key
objecttable = lv_table
classnum = lv_class
classtype = lv_class_type
keydate = sy-datum
language = sy-langu
IMPORTING
status = lv_status
TABLES
allocvaluesnum = lt_alloc_num
allocvalueschar = lt_alloc_char
allocvaluescurr = lt_alloc_curr
return = lt_return.
*--------------------TUS-CHARG-END-----------------------------------*
LOOP AT pt_field INTO ls_field.
CLEAR lv_field.
CONCATENATE 'Z_' ls_field-fieldname INTO lv_field.
ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE ps_batch TO .
IF sy-subrc EQ 0.
CASE ls_field-datatype.
WHEN 'CHAR'.
READ TABLE lt_alloc_char ASSIGNING WITH KEY charact = lv_field.
IF sy-subrc = 0.
IF IS NOT INITIAL.
-charact = lv_field.
-value_char = .
-value_neutral = .
ENDIF.
ELSE.
APPEND INITIAL LINE TO lt_alloc_char ASSIGNING .
-charact = lv_field.
-value_char = .
-value_neutral = .
ENDIF.
IF EQ '999'.
CLEAR : -value_char,-value_neutral.
ENDIF.
WHEN 'DEC' OR 'QUAN'.
READ TABLE lt_alloc_num ASSIGNING WITH KEY charact = lv_field.
IF sy-subrc = 0 .
IF IS NOT INITIAL.
-charact = lv_field.
-value_from = .
-value_to = .
ENDIF.
ELSE.
APPEND INITIAL LINE TO lt_alloc_num ASSIGNING .
-charact = lv_field.
-value_from = .
-value_to = .
ENDIF.
IF EQ 999 .
CLEAR: -value_from,-value_to.
ENDIF.
WHEN 'CURR'.
READ TABLE lt_alloc_curr ASSIGNING WITH KEY charact = lv_field.
IF sy-subrc = 0.
IF IS NOT INITIAL.
-charact = lv_field.
-value_from = .
-currency_from = 'CNY'.
-currency_from_iso = 'CNY'.
ENDIF.
ELSE.
APPEND INITIAL LINE TO lt_alloc_curr ASSIGNING .
-charact = lv_field.
-value_from = .
-currency_from = 'CNY'.
-currency_from_iso = 'CNY'.
ENDIF.
IF EQ 999 .
CLEAR -value_from .
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDIF.
ENDLOOP.
*--------------------TUS-CHARG-BEGIN---------------------------------*
CALL FUNCTION 'BAPI_OBJCL_CHANGE'
EXPORTING
objectkey = lv_key
objecttable = lv_table
classnum = lv_class
classtype = lv_class_type
status = '1'
keydate = sy-datum
IMPORTING
classif_status = lv_status
TABLES
allocvaluesnumnew = lt_alloc_num
allocvaluescharnew = lt_alloc_char
allocvaluescurrnew = lt_alloc_curr
return = lt_return.
*--------------------TUS-CHARG-END-----------------------------------*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
ps_rturn = ls_return.
EXIT.
ENDLOOP.
ENDFORM. " FRM_EDIT_BATCH
阅读(1472) | 评论(0) | 转发(0) |