ABAP布置批处理会话-sm35

ABAP程序做批处理一般用BDC来完成。本文主要讲解如何将BDC放在SM35的会话里。

步骤:

  1. 调用BDC_OPEN_GROUP,通过参数GROUP传入会话名称
  2. 编辑BDC录屏数据,调用函数BDC_INSERT,通过参数TCODE,CTUPARAMS,DYNPROTAB传入BDC相关数据
  3. 调用BDC_CLOSE_GROUP关闭会话

注意点:

  • 第2步,可以循环放入多条数据
    DATA:lv_bdcgroup TYPE char12.
      DATA: bdcdata LIKE STANDARD TABLE OF bdcdata WITH HEADER LINE,
            bdcmsg  LIKE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE.
      MOVE 'JOB_GROUP' TO lv_bdcgroup.
      CALL FUNCTION 'BDC_OPEN_GROUP'
        EXPORTING
          client              = sy-mandt
          group               = lv_bdcgroup
          keep                = 'X'
          user                = sy-uname
        EXCEPTIONS
          client_invalid      = 1
          destination_invalid = 2
          group_invalid       = 3
          group_is_locked     = 4
          holddate_invalid    = 5
          internal_error      = 6
          queue_error         = 7
          running             = 8
          system_lock_error   = 9
          user_invalid        = 10
          OTHERS              = 11.
          
      LOOP AT itab INTO ls_itab.
        CLEAR: bdcdata.
        REFRESH bdcdata.
        
        PERFORM bdc_dynpro      USING 'SAPLCHRG' '1000'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=ENTR'.
        ...
        ...
        PERFORM bdc_dynpro      USING 'SAPLCHRG' '1000'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=SAVE'.
                                      
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            tcode            = 'MM01'
            ctuparams        = t_opt
          TABLES
            dynprotab        = bdcdata
          EXCEPTIONS
            internal_error   = 1
            not_open         = 2
            queue_error      = 3
            tcode_invalid    = 4
            printing_invalid = 5
            posting_invalid  = 6
            OTHERS           = 7.
      ENDLOOP.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
        EXCEPTIONS
          not_open    = 1
          queue_error = 2
          OTHERS      = 3.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值
>