• ABAP BAPI_ACC_DOCUMENT_POST 中 EXTENSION1的用法


    BAPI_ACC_DOCUMENT_POST 在过账会计凭证时候,经常会发现一些标准字段在参数中并没有

    可以通过CMOD/SMOD增强出口--》ACBAPI01--》EXIT_SAPLACC4_001--》ZXACCU15

    示例代码

    1. DATA: wa_extension TYPE bapiextc,
    2. it_extension TYPE STANDARD TABLE OF bapiextc.
    3. wa_extension(3) = '005'. "ITEMNO_ACC
    4. wa_extension+3(11) = 'Note 487722'. "Data, not in standard interface
    5. APPEND wa_extension TO it_extension.
    6. 传递到函数里面
    7. 然后在include中这样写
    8. READ TABLE t_accit WITH KEY posnr = extension(3).
    9. IF sy-subrc IS INITIAL.
    10. * Update the line item text
    11. t_accit-sgtxt = extension+3(11).
    12. MODIFY t_accit INDEX sy-tabix.
    13. ENDIF.

    另外还可以通过BTE的增强:RWBAPI01

    1.FIBF--》设置--》产品--》客户的--》然后新增一条

    2.复制函数 SAMPLE_INTERFACE_RWBAPI01 示例代码

    (SE37-->/SAPPCE/DPC_PROCESS_EXTENSION)

    3.FIBF-->设置--》处理函数模块---》客户的-》新增条目 RWBAPI01 

    另外如果字段还是没找到你要的,可以在如下结构中:append structure

    示例代码:

    1. DATA: LS_EXTEND1 TYPE BAPIACEXTC.
    2. DATA: LT_EXTEND2 TYPE STANDARD TABLE OF BAPIACEXTC.
    3. CLEAR:LS_EXTEND1.
    4. LS_EXTEND1-FIELD1 = LV_BUZEI.
    5. LS_EXTEND1-FIELD2 = 'KUNNR'.
    6. LS_EXTEND1-FIELD3 = '0000001000'.
    7. APPEND LS_EXTEND1 TO LT_EXTEND1.

    1. FUNCTION /sappce/dpc_process_extension.
    2. *"----------------------------------------------------------------------
    3. *"*"Lokale Schnittstelle:
    4. *" TABLES
    5. *" IT_ACCIT STRUCTURE ACCIT
    6. *" IT_ACCCR STRUCTURE ACCCR
    7. *" RETURN STRUCTURE BAPIRET2
    8. *" EXTENSION STRUCTURE BAPIACEXTC
    9. *" IT_ACCWT STRUCTURE ACCIT_WT
    10. *" CHANGING
    11. *" VALUE(DOCUMENT_HEADER) LIKE ACCHD STRUCTURE ACCHD
    12. *"----------------------------------------------------------------------
    13. DATA ld_tabix TYPE sy-tabix.
    14. DATA ld_posnr TYPE posnr_acc.
    15. DATA ls_bapi_extension TYPE bapiacextc.
    16. DATA ls_accit TYPE accit.
    17. DATA ls_acccr TYPE acccr.
    18. DATA ls_accit_wt TYPE accit_wt.
    19. DATA ld_shkzg TYPE shkzg.
    20. DATA ld_currtyp TYPE acccr-currtyp. "N1282263
    21. * process extension data
    22. LOOP AT extension INTO ls_bapi_extension.
    23. ld_posnr = ls_bapi_extension-field1.
    24. * evaluate fieldname
    25. CASE ls_bapi_extension-field2.
    26. WHEN c_ext_document_status.
    27. * set document Status
    28. READ TABLE it_accit INTO ls_accit
    29. WITH KEY posnr = ld_posnr.
    30. CHECK sy-subrc EQ 0.
    31. ld_tabix = sy-tabix.
    32. ls_accit-bstat = ls_bapi_extension-field3.
    33. * modify document item
    34. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    35. WHEN c_ext_wbs_element.
    36. * set wbs element
    37. READ TABLE it_accit INTO ls_accit
    38. WITH KEY posnr = ld_posnr.
    39. CHECK sy-subrc EQ 0.
    40. ld_tabix = sy-tabix.
    41. ls_accit-ps_psp_pnr = ls_bapi_extension-field3.
    42. * modify document item
    43. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    44. WHEN c_ext_target_sp_ind.
    45. READ TABLE it_accit INTO ls_accit
    46. WITH KEY posnr = ld_posnr.
    47. CHECK sy-subrc EQ 0.
    48. ld_tabix = sy-tabix.
    49. * set target special G/L indicator
    50. ls_accit-zumsk = ls_bapi_extension-field3.
    51. * modify document item
    52. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    53. WHEN c_ext_tax_code.
    54. * set tax code
    55. READ TABLE it_accit INTO ls_accit
    56. WITH KEY posnr = ld_posnr.
    57. CHECK sy-subrc EQ 0.
    58. ld_tabix = sy-tabix.
    59. ls_accit-mwskz = ls_bapi_extension-field3.
    60. * modify document item
    61. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    62. WHEN c_ext_tax_base_amount.
    63. * set tax base amount
    64. IF ls_bapi_extension-field4 IS INITIAL. "N1282263
    65. ld_currtyp = '00'. "N1282263
    66. ELSE. "N1282263
    67. ld_currtyp = ls_bapi_extension-field4. "N1282263
    68. ENDIF. "N1282263
    69. READ TABLE it_acccr INTO ls_acccr
    70. WITH KEY posnr = ld_posnr "N1282263
    71. curtp = ld_currtyp. "N1282263
    72. * WITH KEY posnr = ld_posnr. "N1282263
    73. CHECK sy-subrc EQ 0.
    74. ld_tabix = sy-tabix.
    75. ls_acccr-wmwst = ls_bapi_extension-field3.
    76. * modify document item
    77. MODIFY it_acccr FROM ls_acccr INDEX ld_tabix.
    78. WHEN c_ext_stat_tax_amount.
    79. * set statistic tax amount
    80. READ TABLE it_accit INTO ls_accit
    81. WITH KEY posnr = ld_posnr.
    82. CHECK sy-subrc EQ 0.
    83. ld_tabix = sy-tabix.
    84. ls_accit-sttax = ls_bapi_extension-field3.
    85. * modify document item
    86. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    87. WHEN c_ext_stat_tax_amount_ccc.
    88. * set statistic tax amount (company code currency)
    89. READ TABLE it_accit INTO ls_accit
    90. WITH KEY posnr = ld_posnr.
    91. CHECK sy-subrc EQ 0.
    92. ld_tabix = sy-tabix.
    93. ls_accit-sthtx = ls_bapi_extension-field3.
    94. * modify document item
    95. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    96. * set WT_KEY for CREDITOR, if creditor is subject to withholding tax
    97. WHEN c_ext_with_tax_creditor.
    98. READ TABLE it_accit INTO ls_accit
    99. WITH KEY posnr = ld_posnr.
    100. CHECK sy-subrc EQ 0.
    101. ld_tabix = sy-tabix.
    102. ls_accit-wt_key = ls_bapi_extension-field3.
    103. ls_accit-qsskz = 'XX'.
    104. * modify document item
    105. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    106. * set withholding tax
    107. WHEN c_ext_withholding_tax.
    108. CLEAR ls_accit_wt.
    109. ls_accit_wt-wt_key = ls_bapi_extension-field1+0(6).
    110. ls_accit_wt-witht = ls_bapi_extension-field1+6(2).
    111. ls_accit_wt-wt_withcd = ls_bapi_extension-field1+8(2).
    112. ld_shkzg = ls_bapi_extension-field1+10(1).
    113. ls_accit_wt-wt_qsshb = ls_bapi_extension-field3.
    114. ls_accit_wt-wt_qbuihb = ls_bapi_extension-field4.
    115. APPEND ls_accit_wt TO it_accwt.
    116. WHEN c_ext_activity.
    117. * set activity for down payment requests
    118. READ TABLE it_accit INTO ls_accit
    119. WITH KEY posnr = ld_posnr.
    120. CHECK sy-subrc EQ 0.
    121. ld_tabix = sy-tabix.
    122. ls_accit-vorgn = ls_bapi_extension-field3.
    123. * modify document item
    124. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    125. *** header data *****************************************
    126. WHEN c_ext_business_transaction.
    127. * change activity (needed for CA-JVA)
    128. document_header-glvor = ls_bapi_extension-field3.
    129. WHEN c_ext_transaction_code.
    130. * change transaction code (needed for CA-JVA)
    131. document_header-tcode = ls_bapi_extension-field3.
    132. WHEN c_ext_invoice_reference.
    133. * set invoice reference
    134. READ TABLE it_accit INTO ls_accit
    135. WITH KEY posnr = ld_posnr.
    136. CHECK sy-subrc EQ 0.
    137. ld_tabix = sy-tabix.
    138. ls_accit-rebzg = ls_bapi_extension-field3.
    139. * modify document item
    140. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    141. WHEN c_ext_invoice_reference_year.
    142. * set invoice reference year
    143. READ TABLE it_accit INTO ls_accit
    144. WITH KEY posnr = ld_posnr.
    145. CHECK sy-subrc EQ 0.
    146. ld_tabix = sy-tabix.
    147. ls_accit-rebzj = ls_bapi_extension-field3.
    148. * modify document item
    149. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    150. WHEN c_ext_invoice_reference_item.
    151. * set invoice reference item
    152. READ TABLE it_accit INTO ls_accit
    153. WITH KEY posnr = ld_posnr.
    154. CHECK sy-subrc EQ 0.
    155. ld_tabix = sy-tabix.
    156. ls_accit-rebzz = ls_bapi_extension-field3.
    157. * modify document item
    158. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    159. WHEN c_ext_sub_document_type.
    160. * set type of subsequent document
    161. READ TABLE it_accit INTO ls_accit
    162. WITH KEY posnr = ld_posnr.
    163. CHECK sy-subrc EQ 0.
    164. ld_tabix = sy-tabix.
    165. ls_accit-rebzt = ls_bapi_extension-field3.
    166. * modify document item
    167. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    168. WHEN c_ext_invoice_reference_check.
    169. * set invoice reference check = NO
    170. READ TABLE it_accit INTO ls_accit
    171. WITH KEY posnr = ld_posnr.
    172. CHECK sy-subrc EQ 0.
    173. ld_tabix = sy-tabix.
    174. ls_accit-rebzg_check = ls_bapi_extension-field3.
    175. * modify document item
    176. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    177. WHEN c_ext_allocation.
    178. * fill allocation for tax items
    179. READ TABLE it_accit INTO ls_accit
    180. WITH KEY posnr = ld_posnr.
    181. CHECK sy-subrc EQ 0.
    182. ld_tabix = sy-tabix.
    183. ls_accit-zuonr = ls_bapi_extension-field3.
    184. * modify document item
    185. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    186. * insert XAUTO for tax clearing lines
    187. WHEN c_xauto.
    188. READ TABLE it_accit INTO ls_accit
    189. WITH KEY posnr = ld_posnr.
    190. CHECK sy-subrc EQ 0.
    191. ld_tabix = sy-tabix.
    192. ls_accit-xauto = ls_bapi_extension-field3.
    193. * modify document item
    194. MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    195. ** insert cash discount amount "#976257 "N1140971
    196. * when c_ext_cash_discount_amount. "#976257 "N1140971
    197. * read table it_acccr into ls_acccr "#976257 "N1140971
    198. * with key posnr = ld_posnr. "#976257 "N1140971
    199. * check sy-subrc eq 0. "#976257 "N1140971
    200. * ld_tabix = sy-tabix. "#976257 "N1140971
    201. * ls_acccr-wskto = ls_bapi_extension-field3. "#976257 "N1140971
    202. ** modify document item "#976257 "N1140971
    203. * modify it_acccr from ls_acccr index ld_tabix. "#976257 "N1140971
    204. * insert posting key (requested by functionality DBM) "#976257
    205. when c_ext_posting_key. "#976257
    206. read table it_accit into ls_accit "#976257
    207. with key posnr = ld_posnr. "#976257
    208. check sy-subrc eq 0. "#976257
    209. ld_tabix = sy-tabix. "#976257
    210. ls_accit-bschl = ls_bapi_extension-field3. "#976257
    211. * modify document item "#976257
    212. modify it_accit from ls_accit index ld_tabix. "#976257
    213. * others
    214. WHEN OTHERS.
    215. CONTINUE.
    216. ENDCASE.
    217. ENDLOOP.
    218. ENDFUNCTION.

  • 相关阅读:
    redis持久化之RDB (七)
    设计模式之美——单元测试和代码可测性
    c小白勇闯结构体!!!!
    vue3怎么动态使用style
    FreeRTOS自我救赎3之USB虚拟串口
    Selenium 获取请求响应
    B. Kalindrome Array
    17. 电话号码的字母组合
    【Designing ML Systems】第 9 章 :生产中的持续学习和测试
    Python钢筋混凝土结构计算.pdf-T001-混凝土强度设计值
  • 原文地址:https://blog.csdn.net/IamRunjiang/article/details/132758398