本文主要是介绍ABAP 最好用BDC模板,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、BDC
使用SHDB录制之后,要把操作步骤写入程序里面去,每次都觉好麻烦,都不晓得怎么写。看别人都是用performs 一点点写进去。但是我觉得方法不直观,所以找到更加直观的方法。
只要一一对应填写进去就好了,非常好用。
二、源代码
DATA bdcdata TYPE bdcdata OCCURS 0.DATA l_bdcmsg LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.DATA:zmes TYPE string.LOOP AT gt_alv ASSIGNING FIELD-SYMBOL(<ls_alv>) WHERE cbox = 'X'.bdcdata = VALUE #(( program = 'SAPLCOKO1' dynpro = '0110' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=ENTK' )( program = '' dynpro = '' dynbegin = '' fnam = 'CAUFVD-AUFNR' fval = <ls_alv>-AUFNR )( program = '' dynpro = '' dynbegin = '' fnam = 'R62CLORD-FLG_OVIEW' fval = 'X' )( program = 'SAPLCOKO1' dynpro = '0115' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=KOBK' )( program = 'SAPLKOBS' dynpro = '0130' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_CURSOR' fval = 'DKOBR-EMPGE(02)' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=DETA' )( program = 'SAPLKOBS' dynpro = '0100' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '/00' )( program = 'SAPLKOBS' dynpro = '0100' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=BACK' )( program = 'SAPLKOBS' dynpro = '0130' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=BACK' )( program = 'SAPMSSY0' dynpro = '0120' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=&ONT' )( program = 'SAPLCOKO1' dynpro = '0115' dynbegin = 'X' fnam = '' fval = '' )( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=BU' )).CALL TRANSACTION 'CO02' USING bdcdata MODE 'N' MESSAGES INTO l_bdcmsg.WAIT UP TO '0.02' SECONDS.IF l_bdcmsg[] IS INITIAL .<ls_alv>-icons = icon_green_light .<ls_alv>-mes = '操作成功'.ELSE.LOOP AT l_bdcmsg.CALL FUNCTION 'MESSAGE_TEXT_BUILD'EXPORTINGmsgid = l_bdcmsg-msgidmsgnr = l_bdcmsg-msgnrmsgv1 = l_bdcmsg-msgv1msgv2 = l_bdcmsg-msgv2msgv3 = l_bdcmsg-msgv3msgv4 = l_bdcmsg-msgv4IMPORTINGmessage_text_output = zmes.ENDLOOP." <ls_alv>-icons = icon_red_light .<ls_alv>-mes = zmes.CLEAR:zmes.ENDIF.
ENDLOOP.
CLEAR:l_bdcmsg,l_bdcmsg[].
三、注意点
BDC_SUBSCR ,表示鼠标停留经过的意思。有时候可以忽略不写。
BDC_CURSOR,表示鼠标点击
BDC_OKCODE,表示回车以及一些操作,这个非常重要
分享使我快乐,我是寒武青锋。
记得点赞哈。
这篇关于ABAP 最好用BDC模板的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!