发博文
Sap.Felix

abaptiner.blog.chinaunix.net

   
个人资料
  • 博客访问:13922
  • 博文数量:13
  • 博客积分:1455
  • 博客等级:上尉
  • 注册时间:2009-09-03 12:48:29
订阅我的博客
  • 订阅
  • 订阅到鲜果
  • 订阅到抓虾
  • 订阅到Google
字体大小: 博文
BDC录屏简易库 (2011-11-17 13:16)
标签SAP  abap  BDC  SHDB  分类: ABAP



 

  1. TYPE-POOL zbdc .
  2. *&&---------------------------------------------------------------*
  3. *&& Description:Library for using bdc
  4. *&& Author:felix
  5. *&& Version:1.0
  6. *&& QQ:76985807
  7. *&& Email:abaptiner@foxmail.com
  8. *&& note:open source,anyone can use and modify it.
  9. *&&---------------------------------------------------------------*
  10. CONSTANTS:zbdc_empty_tag TYPE c VALUE '~'.

  11. *&&---------------------------------------------------------------*
  12. *&& initialize variants
  13. *&&---------------------------------------------------------------*
  14. *&& Note:You can use this macro to define all bdc variants
  15. *&&    simply just like example below.
  16. *&& Example:
  17. *&& zbdc_init.
  18. *&&---------------------------------------------------------------*
  19. DEFINE zbdc_init.
  20.   data:wa_zbdc_line type bdcdata.
  21.   data:lt_bdc_tab type standard table of bdcdata.
  22.   data:lt_bdc_option type standard table of ctu_params,
  23.        ls_bdc_option type ctu_params.
  24.   data:lt_bdc_message type standard table of bdcmsgcoll.
  25. END-OF-DEFINITION.
  26. *&&---------------------------------------------------------------*
  27. *&& Append a bdc field or screen line which copy from shdb
  28. *&&---------------------------------------------------------------*
  29. *&& Note:With this macro,you can copy bdc records to excel and
  30. *&&    edit.Replace empty fields with ~.
  31. *&& Example:
  32. *&& zbdc_raw_line:
  33. *&&        SAPMF02D    0101    X         
  34. *&& ~ ~ ~ BDC_CURSOR    RF02D-D0324
  35. *&& ~ ~ ~ BDC_OKCODE    /00
  36. *&& ~ ~ ~ RF02D-KUNNR    1010003.
  37. *&&---------------------------------------------------------------*
  38. DEFINE zbdc_raw_line.
  39.   clear wa_zbdc_line.
  40.   if '&1' <> zbdc_empty_tag.
  41.     wa_zbdc_line-program = '&1'.
  42.   else.
  43.     wa_zbdc_line-program = ''.
  44.   endif.
  45.   if '&2' <> zbdc_empty_tag.
  46.     wa_zbdc_line-dynpro = '&2'.
  47.   else.
  48.     wa_zbdc_line-dynpro = ''.
  49.   endif.
  50.   if '&3' <> zbdc_empty_tag.
  51.     wa_zbdc_line-dynbegin = '&3'.
  52.   else.
  53.     wa_zbdc_line-dynbegin = ''.
  54.   endif.
  55.   if '&4' <> zbdc_empty_tag.
  56.     wa_zbdc_line-fnam = '&4'.
  57.   else.
  58.     wa_zbdc_line-fnam = ''.
  59.   endif.
  60.   if '&5' <> zbdc_empty_tag.
  61.     wa_zbdc_line-fval = '&5'.
  62.   else.
  63.     wa_zbdc_line-fval = ''.
  64.   endif.
  65.   append wa_zbdc_line to lt_bdc_tab.
  66. END-OF-DEFINITION.
  67. *&& append bdc screen
  68. DEFINE zbdc_screen.
  69.   clear wa_zbdc_line.
  70.   wa_zbdc_line-program = &1.
  71.   wa_zbdc_line-dynpro = &2.
  72.   wa_zbdc_line-dynbegin = &3.
  73.   append wa_zbdc_line to lt_bdc_tab.
  74. END-OF-DEFINITION.
  75. *&& append bdc field
  76. DEFINE zbdc_field.
  77.   clear wa_zbdc_line.
  78.   wa_zbdc_line-fnam = &1.
  79.   wa_zbdc_line-fval = &2.
  80.   append wa_zbdc_line to lt_bdc_tab.
  81. END-OF-DEFINITION.
  82. *&& call transaction using default mode 'E'
  83. DEFINE zbdc_call_trans.
  84.   clear ls_bdc_option.
  85.   ls_bdc_option-dismode = 'E'.
  86.   ls_bdc_option-updmode = 'S'.
  87.   ls_bdc_option-NOBINPT = ''.
  88.   call transaction &1
  89.     using lt_bdc_tab
  90.     options from ls_bdc_option
  91.     messages into lt_bdc_message.
  92. END-OF-DEFINITION.
  93. *&& call transaction using mode 'E'
  94. DEFINE zbdc_call_trans_e.
  95.   zbdc_call_trans.
  96. END-OF-DEFINITION.
  97. *&& call transaction using mode 'A'
  98. DEFINE zbdc_call_trans_a.
  99.   clear ls_bdc_option.
  100.   ls_bdc_option-dismode = 'A'.
  101.   ls_bdc_option-updmode = 'S'.
  102.   call transaction &1
  103.     using lt_bdc_tab
  104.     options from ls_bdc_option
  105.     messages into lt_bdc_message.
  106. END-OF-DEFINITION.
  107. *&& call transaction using mode 'N'
  108. DEFINE zbdc_call_trans_n.
  109.   clear ls_bdc_option.
  110.   ls_bdc_option-dismode = 'N'.
  111.   ls_bdc_option-updmode = 'S'.
  112.   call transaction &1
  113.     using lt_bdc_tab
  114.     options from ls_bdc_option
  115.     messages into lt_bdc_message.
  116. END-OF-DEFINITION.
  117. *&& get bdc message
  118. DEFINE zbdc_get_message.
  119.   &1 = lt_bdc_message.
  120. END-OF-DEFINITION.

博客推荐文章
前一篇:SAP还能走多远
亲,您还没有登录,请[登录][注册]后再进行评论