Chinaunix首页 | 论坛 | 博客
  • 博客访问: 481433
  • 博文数量: 199
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2020-05-14 13:25
个人简介

代码5S

文章分类

全部博文(199)

文章存档

2021年(5)

2020年(194)

我的朋友

分类: 其他平台

2020-06-23 10:18:40


点击(此处)折叠或打开

  1. FORM frm_edit_batch TABLES pt_field STRUCTURE dfies
  2.                        USING ps_batch TYPE ty_batch
  3.                     CHANGING ps_rturn TYPE bapiret2.

  4.   DATA : lv_key TYPE bapi1003_key-object,
  5.          lv_table TYPE bapi1003_key-objecttable VALUE 'MCH1',
  6.          lv_class TYPE bapi1003_key-classnum VALUE 'Z_CLASS_BATCH',
  7.          lv_class_type TYPE bapi1003_key-classtype VALUE '023',
  8.          lv_status TYPE bapi1003_key-status,
  9. *--------------------TUS-CHARG-BEGIN---------------------------------*
  10.          lt_alloc_curr TYPE TABLE OF zbapi1003_alloc_values_curr,
  11.          lt_alloc_num TYPE TABLE OF zbapi1003_alloc_values_num,
  12.          lt_alloc_char TYPE TABLE OF zbapi1003_alloc_values_char,
  13. *--------------------TUS-CHARG-END-----------------------------------*
  14.          lt_return TYPE TABLE OF bapiret2,
  15.          ls_return TYPE bapiret2.
  16.   DATA:ls_field TYPE dfies,
  17.        lv_field(100) TYPE c.

  18. *--------------------TUS-CHARG-BEGIN---------------------------------*
  19.   FIELD-SYMBOLS:
  20.     <fs_s_alloc_curr> TYPE zbapi1003_alloc_values_curr,
  21.     <fs_s_alloc_char> TYPE zbapi1003_alloc_values_char,
  22.     <fs_s_alloc_num> TYPE zbapi1003_alloc_values_num,
  23.     <fs_value>.
  24. *--------------------TUS-CHARG-END-----------------------------------*
  25.   REFRESH:lt_alloc_curr,lt_return,lt_alloc_num,lt_alloc_char.
  26.   CLEAR:lv_key,lv_status,ls_return.

  27.   lv_key+0(18) = ps_batch-matnr.
  28.   lv_key+18(10) = ps_batch-charg.
  29. *--------------------TUS-CHARG-BEGIN---------------------------------*
  30.   CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
  31.     EXPORTING
  32.       objectkey = lv_key
  33.       objecttable = lv_table
  34.       classnum = lv_class
  35.       classtype = lv_class_type
  36.       keydate = sy-datum
  37.       language = sy-langu
  38.     IMPORTING
  39.       status = lv_status
  40.     TABLES
  41.       allocvaluesnum = lt_alloc_num
  42.       allocvalueschar = lt_alloc_char
  43.       allocvaluescurr = lt_alloc_curr
  44.       return = lt_return.
  45. *--------------------TUS-CHARG-END-----------------------------------*
  46.   LOOP AT pt_field INTO ls_field.
  47.     CLEAR lv_field.
  48.     CONCATENATE 'Z_' ls_field-fieldname INTO lv_field.

  49.     ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE ps_batch TO <fs_value>.
  50.     IF sy-subrc EQ 0.
  51.       CASE ls_field-datatype.
  52.         WHEN 'CHAR'.
  53.           READ TABLE lt_alloc_char ASSIGNING <fs_s_alloc_char> WITH KEY charact = lv_field.
  54.           IF sy-subrc = 0.
  55.             IF <fs_value> IS NOT INITIAL.
  56.               <fs_s_alloc_char>-charact = lv_field.
  57.               <fs_s_alloc_char>-value_char = <fs_value>.
  58.               <fs_s_alloc_char>-value_neutral = <fs_value>.
  59.             ENDIF.
  60.           ELSE.
  61.             APPEND INITIAL LINE TO lt_alloc_char ASSIGNING <fs_s_alloc_char>.
  62.             <fs_s_alloc_char>-charact = lv_field.
  63.             <fs_s_alloc_char>-value_char = <fs_value>.
  64.             <fs_s_alloc_char>-value_neutral = <fs_value>.
  65.           ENDIF.
  66.           IF <fs_value> EQ '999'.
  67.             CLEAR : <fs_s_alloc_char>-value_char,<fs_s_alloc_char>-value_neutral.
  68.           ENDIF.

  69.         WHEN 'DEC' OR 'QUAN'.
  70.           READ TABLE lt_alloc_num ASSIGNING <fs_s_alloc_num> WITH KEY charact = lv_field.
  71.           IF sy-subrc = 0 .
  72.             IF <fs_value> IS NOT INITIAL.
  73.               <fs_s_alloc_num>-charact = lv_field.
  74.               <fs_s_alloc_num>-value_from = <fs_value>.
  75.               <fs_s_alloc_num>-value_to = <fs_value>.
  76.             ENDIF.
  77.           ELSE.
  78.             APPEND INITIAL LINE TO lt_alloc_num ASSIGNING <fs_s_alloc_num>.
  79.             <fs_s_alloc_num>-charact = lv_field.
  80.             <fs_s_alloc_num>-value_from = <fs_value>.
  81.             <fs_s_alloc_num>-value_to = <fs_value>.
  82.           ENDIF.
  83.           IF <fs_value> EQ 999 .
  84.             CLEAR: <fs_s_alloc_num>-value_from,<fs_s_alloc_num>-value_to.
  85.           ENDIF.

  86.         WHEN 'CURR'.
  87.           READ TABLE lt_alloc_curr ASSIGNING <fs_s_alloc_curr> WITH KEY charact = lv_field.
  88.           IF sy-subrc = 0.
  89.             IF <fs_value> IS NOT INITIAL.
  90.               <fs_s_alloc_curr>-charact = lv_field.
  91.               <fs_s_alloc_curr>-value_from = <fs_value>.
  92.               <fs_s_alloc_curr>-currency_from = 'CNY'.
  93.               <fs_s_alloc_curr>-currency_from_iso = 'CNY'.
  94.             ENDIF.
  95.           ELSE.
  96.             APPEND INITIAL LINE TO lt_alloc_curr ASSIGNING <fs_s_alloc_curr>.
  97.             <fs_s_alloc_curr>-charact = lv_field.
  98.             <fs_s_alloc_curr>-value_from = <fs_value>.
  99.             <fs_s_alloc_curr>-currency_from = 'CNY'.
  100.             <fs_s_alloc_curr>-currency_from_iso = 'CNY'.
  101.           ENDIF.
  102.           IF <fs_value> EQ 999 .
  103.             CLEAR <fs_s_alloc_curr>-value_from .
  104.           ENDIF.
  105.         WHEN OTHERS.
  106.       ENDCASE.
  107.     ENDIF.
  108.   ENDLOOP.

  109. *--------------------TUS-CHARG-BEGIN---------------------------------*
  110.   CALL FUNCTION 'BAPI_OBJCL_CHANGE'
  111.     EXPORTING
  112.       objectkey = lv_key
  113.       objecttable = lv_table
  114.       classnum = lv_class
  115.       classtype = lv_class_type
  116.       status = '1'
  117.       keydate = sy-datum
  118.     IMPORTING
  119.       classif_status = lv_status
  120.     TABLES
  121.       allocvaluesnumnew = lt_alloc_num
  122.       allocvaluescharnew = lt_alloc_char
  123.       allocvaluescurrnew = lt_alloc_curr
  124.       return = lt_return.
  125. *--------------------TUS-CHARG-END-----------------------------------*
  126.   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  127.     EXPORTING
  128.       wait = 'X'.

  129.   LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
  130.     ps_rturn = ls_return.
  131.     EXIT.
  132.   ENDLOOP.

  133. ENDFORM.

阅读(2006) | 评论(0) | 转发(0) |
0

上一篇:MSC3N批次修改

下一篇:ABAP获取期末库存

给主人留下些什么吧!~~