Posted By

Birdych on 01/15/18


Tagged

BSEG


Versions (?)

ZCL_VM_BSEG


 / Published in: Pseudocode
 

Verwaltung von BSEG-Zugriffen

  1. class ZCL_VM_BSEG definition
  2. public
  3. create private .
  4.  
  5. public section.
  6.  
  7. types:
  8. BEGIN OF ty_all_slips,
  9. bukrs TYPE bukrs,
  10. belnr TYPE belnr_d,
  11. kdauf TYPE kdauf,
  12. END OF ty_all_slips .
  13. types:
  14. ty_all_slips_tab TYPE STANDARD TABLE OF ty_all_slips
  15. WITH NON-UNIQUE KEY bukrs belnr .
  16. types:
  17. TY_MANSP_RANGE_TAB type RANGE OF MANSP .
  18. types:
  19. BEGIN OF ty_short_bseg,
  20. bukrs TYPE bukrs,
  21. belnr TYPE belnr_d,
  22. gjahr TYPE gjahr,
  23. buzei TYPE buzei,
  24. augbl TYPE augbl,
  25. bschl TYPE bschl,
  26. pswbt TYPE pswbt,
  27. pswsl TYPE pswsl,
  28. zuonr TYPE dzuonr,
  29. vbeln TYPE vbeln_vf,
  30. kunnr TYPE kunnr,
  31. zfbdt TYPE dzfbdt,
  32. mansp TYPE mansp,
  33. madat TYPE madat,
  34. manst TYPE mahns_d,
  35. maber TYPE maber,
  36. matnr TYPE matnr,
  37. END OF ty_short_bseg .
  38. types:
  39. ty_short_bseg_tab TYPE STANDARD TABLE OF ty_short_bseg
  40. WITH NON-UNIQUE KEY bukrs belnr gjahr buzei .
  41.  
  42. data GT_BSEG type TY_SHORT_BSEG_TAB .
  43.  
  44. class-methods GET_BSEG_DATA
  45. importing
  46. !IT_BUKRS_KDAUF_LIST type TY_ALL_SLIPS_TAB optional
  47. !IT_KDAUF_LIST type TT_VBELN optional
  48. !IT_BUKRS_LIST type T_BUKRS optional
  49. !IV_KDAUF type KDAUF optional
  50. !IV_BUKRS type BUKRS optional
  51. !IV_OP type BOOLE_D optional
  52. !IV_BSCHL type BSCHL optional
  53. !IRT_MANSP type TY_MANSP_RANGE_TAB optional
  54. !IV_MABER type MABER optional
  55. !IV_MANST type MAHNS_D optional
  56. exporting
  57. !ET_BSEG type TY_SHORT_BSEG_TAB
  58. !EO_BSEG type ref to ZCL_VM_BSEG .
  59. methods UPDATE_BSEG
  60. importing
  61. !IT_BSEG type TY_SHORT_BSEG_TAB optional
  62. !IV_NEW_MABER type MABER optional
  63. !IV_NEW_MANSP type MANSP optional
  64. !IV_NEW_MANST type MAHNS_D optional
  65. !IV_NEW_MADAT type MADAT optional
  66. !IV_NEW_ZFBDT type DZFBDT optional
  67. exceptions
  68. UPDATE_ERROR .
  69. protected section.
  70. private section.
  71.  
  72. types:
  73. TY_ACCCHG_TAB type STANDARD TABLE OF ACCCHG .
  74.  
  75. methods FI_DOCUMENT_CHANGE
  76. importing
  77. !IS_BSEG type TY_SHORT_BSEG
  78. !IT_ACCCHG type TY_ACCCHG_TAB
  79. exceptions
  80. UPDATE_ERROR .
  81. class-methods GET_PARAM_LIST
  82. importing
  83. !IT_TABLE type STANDARD TABLE
  84. !IV_PARAM type DATA
  85. exporting
  86. !ET_LIST type STANDARD TABLE .
  87. methods LOG_BSEG_CHANGES
  88. importing
  89. !IS_BSEG type TY_SHORT_BSEG
  90. !IT_ACCCHG type FDM_T_ACCCHG .
  91. class-methods GET_STANDARD_COND_SYNTAX
  92. importing
  93. !IV_OP type BOOLE_D
  94. !IV_BSCHL type BSCHL
  95. !IRT_MANSP type TY_MANSP_RANGE_TAB
  96. !IV_MABER type MABER
  97. !IV_MANST type MAHNS_D
  98. returning
  99. value(RV_STD_COND_SYNTAX) type STRING .
  100. class-methods SELECT_VIA_VBFA
  101. importing
  102. !IT_KDAUF_LIST type TT_VBELN
  103. !IV_KDAUF type KDAUF
  104. !IV_BUKRS type BUKRS
  105. !IRT_MANSP type TY_MANSP_RANGE_TAB
  106. !IV_STD_COND_SYNTAX type STRING
  107. returning
  108. value(RT_BSEG) type TY_SHORT_BSEG_TAB .
  109. class-methods SELECT_WITH_ALL_SLIPS
  110. importing
  111. !IT_BUKRS_KDAUF_LIST type TY_ALL_SLIPS_TAB
  112. !IV_KDAUF type KDAUF
  113. !IV_BUKRS type BUKRS
  114. !IRT_MANSP type TY_MANSP_RANGE_TAB
  115. !IV_STD_COND_SYNTAX type STRING
  116. returning
  117. value(RT_BSEG) type TY_SHORT_BSEG_TAB .
  118. methods CONSTRUCTOR
  119. importing
  120. !IT_BSEG type TY_SHORT_BSEG_TAB .
  121. class-methods SELECT_WITH_BUKRS_LIST
  122. importing
  123. !IT_BUKRS_LIST type T_BUKRS
  124. !IV_BUKRS type BUKRS
  125. !IRT_MANSP type TY_MANSP_RANGE_TAB
  126. !IV_STD_COND_SYNTAX type STRING
  127. returning
  128. value(RT_BSEG) type TY_SHORT_BSEG_TAB .
  129. methods UPDATE_DOCUMENTS
  130. importing
  131. !IS_BSEG type TY_SHORT_BSEG optional
  132. !IT_ACCCHG type TY_ACCCHG_TAB optional .
  133. ENDCLASS.
  134.  
  135.  
  136.  
  137. CLASS ZCL_VM_BSEG IMPLEMENTATION.
  138.  
  139.  
  140. * <SIGNATURE>---------------------------------------------------------------------------------------+
  141. * | Instance Private Method ZCL_VM_BSEG->CONSTRUCTOR
  142. * +-------------------------------------------------------------------------------------------------+
  143. * | [--->] IT_BSEG TYPE TY_SHORT_BSEG_TAB
  144. * +--------------------------------------------------------------------------------------</SIGNATURE>
  145. METHOD constructor.
  146.  
  147. gt_bseg = it_bseg.
  148.  
  149. ENDMETHOD.
  150.  
  151.  
  152. * <SIGNATURE>---------------------------------------------------------------------------------------+
  153. * | Instance Private Method ZCL_VM_BSEG->FI_DOCUMENT_CHANGE
  154. * +-------------------------------------------------------------------------------------------------+
  155. * | [--->] IS_BSEG TYPE TY_SHORT_BSEG
  156. * | [--->] IT_ACCCHG TYPE TY_ACCCHG_TAB
  157. * | [EXC!] UPDATE_ERROR
  158. * +--------------------------------------------------------------------------------------</SIGNATURE>
  159. METHOD fi_document_change.
  160.  
  161. DATA: lt_accchg TYPE STANDARD TABLE OF accchg,
  162. lv_error_msg TYPE string.
  163.  
  164. lt_accchg = it_accchg. " muss wegen FB-Aufruf lokalisiert werden..
  165.  
  166. CALL FUNCTION 'FI_DOCUMENT_CHANGE'
  167. EXPORTING
  168. i_bukrs = is_bseg-bukrs
  169. i_belnr = is_bseg-belnr
  170. i_gjahr = is_bseg-gjahr
  171. i_buzei = is_bseg-buzei
  172. TABLES
  173. t_accchg = lt_accchg
  174. EXCEPTIONS
  175. no_reference = 1
  176. no_document = 2
  177. many_documents = 3
  178. wrong_input = 4
  179. overwrite_creditcard = 5
  180. OTHERS = 6.
  181.  
  182. IF sy-subrc IS NOT INITIAL.
  183. ROLLBACK WORK. "#EC ROLLBACK
  184. lv_error_msg = replace( val = 'Änderung des Buchhaltungsbeleg zur Zuordnungs-Nr. «&1» fehlgeschlagen!'(013)
  185. sub = '&1' with = is_bseg-zuonr ).
  186. MESSAGE lv_error_msg TYPE 'E' RAISING update_error.
  187. ENDIF.
  188.  
  189. ENDMETHOD.
  190.  
  191.  
  192. * <SIGNATURE>---------------------------------------------------------------------------------------+
  193. * | Static Public Method ZCL_VM_BSEG=>GET_BSEG_DATA
  194. * +-------------------------------------------------------------------------------------------------+
  195. * | [--->] IT_BUKRS_KDAUF_LIST TYPE TY_ALL_SLIPS_TAB(optional)
  196. * | [--->] IT_KDAUF_LIST TYPE TT_VBELN(optional)
  197. * | [--->] IT_BUKRS_LIST TYPE T_BUKRS(optional)
  198. * | [--->] IV_KDAUF TYPE KDAUF(optional)
  199. * | [--->] IV_BUKRS TYPE BUKRS(optional)
  200. * | [--->] IV_OP TYPE BOOLE_D(optional)
  201. * | [--->] IV_BSCHL TYPE BSCHL(optional)
  202. * | [--->] IRT_MANSP TYPE TY_MANSP_RANGE_TAB(optional)
  203. * | [--->] IV_MABER TYPE MABER(optional)
  204. * | [--->] IV_MANST TYPE MAHNS_D(optional)
  205. * | [<---] ET_BSEG TYPE TY_SHORT_BSEG_TAB
  206. * | [<---] EO_BSEG TYPE REF TO ZCL_VM_BSEG
  207. * +--------------------------------------------------------------------------------------</SIGNATURE>
  208. METHOD get_bseg_data.
  209.  
  210. DATA: lv_std_cond_syntax TYPE string.
  211.  
  212. CLEAR et_bseg.
  213.  
  214. lv_std_cond_syntax = get_standard_cond_syntax( iv_op = iv_op
  215. iv_bschl = iv_bschl
  216. irt_mansp = irt_mansp
  217. iv_maber = iv_maber
  218. iv_manst = iv_manst ).
  219.  
  220. IF it_bukrs_kdauf_list IS NOT INITIAL.
  221. et_bseg = select_with_all_slips( it_bukrs_kdauf_list = it_bukrs_kdauf_list
  222. iv_kdauf = iv_kdauf
  223. iv_bukrs = iv_bukrs
  224. irt_mansp = irt_mansp
  225. iv_std_cond_syntax = lv_std_cond_syntax ).
  226.  
  227. ELSEIF it_kdauf_list IS NOT INITIAL OR iv_kdauf IS NOT INITIAL.
  228. et_bseg = select_via_vbfa( it_kdauf_list = it_kdauf_list
  229. iv_kdauf = iv_kdauf
  230. iv_bukrs = iv_bukrs
  231. irt_mansp = irt_mansp
  232. iv_std_cond_syntax = lv_std_cond_syntax ).
  233.  
  234. ELSEIF it_bukrs_list IS NOT INITIAL OR iv_bukrs IS NOT INITIAL.
  235. et_bseg = select_with_bukrs_list( it_bukrs_list = it_bukrs_list
  236. iv_bukrs = iv_bukrs
  237. irt_mansp = irt_mansp
  238. iv_std_cond_syntax = lv_std_cond_syntax ).
  239. ENDIF.
  240.  
  241. IF eo_bseg IS SUPPLIED.
  242. CREATE OBJECT eo_bseg TYPE zcl_vm_bseg EXPORTING it_bseg = et_bseg.
  243. ENDIF.
  244.  
  245. ENDMETHOD.
  246.  
  247.  
  248. * <SIGNATURE>---------------------------------------------------------------------------------------+
  249. * | Static Private Method ZCL_VM_BSEG=>GET_PARAM_LIST
  250. * +-------------------------------------------------------------------------------------------------+
  251. * | [--->] IT_TABLE TYPE STANDARD TABLE
  252. * | [--->] IV_PARAM TYPE DATA
  253. * | [<---] ET_LIST TYPE STANDARD TABLE
  254. * +--------------------------------------------------------------------------------------</SIGNATURE>
  255. METHOD get_param_list.
  256.  
  257. IF it_table IS NOT INITIAL.
  258. et_list = it_table.
  259. ENDIF.
  260.  
  261. IF iv_param IS NOT INITIAL.
  262. APPEND iv_param TO et_list.
  263. ENDIF.
  264.  
  265. ENDMETHOD.
  266.  
  267.  
  268. * <SIGNATURE>---------------------------------------------------------------------------------------+
  269. * | Static Private Method ZCL_VM_BSEG=>GET_STANDARD_COND_SYNTAX
  270. * +-------------------------------------------------------------------------------------------------+
  271. * | [--->] IV_OP TYPE BOOLE_D
  272. * | [--->] IV_BSCHL TYPE BSCHL
  273. * | [--->] IRT_MANSP TYPE TY_MANSP_RANGE_TAB
  274. * | [--->] IV_MABER TYPE MABER
  275. * | [--->] IV_MANST TYPE MAHNS_D
  276. * | [<-()] RV_STD_COND_SYNTAX TYPE STRING
  277. * +--------------------------------------------------------------------------------------</SIGNATURE>
  278. METHOD GET_STANDARD_COND_SYNTAX.
  279.  
  280. IF iv_op = abap_true.
  281. rv_std_cond_syntax = rv_std_cond_syntax && ` AND augbl = ''`.
  282. ENDIF.
  283.  
  284. IF iv_bschl IS NOT INITIAL.
  285. rv_std_cond_syntax = rv_std_cond_syntax && ` AND bschl = '` && iv_bschl && `'`.
  286. ENDIF.
  287.  
  288. IF irt_mansp IS NOT INITIAL.
  289. rv_std_cond_syntax = rv_std_cond_syntax && ` AND mansp IN irt_mansp`.
  290. ENDIF.
  291.  
  292. IF iv_maber IS NOT INITIAL.
  293. rv_std_cond_syntax = rv_std_cond_syntax && ` AND maber = '` && iv_maber && `'`.
  294. ENDIF.
  295.  
  296. IF iv_manst IS NOT INITIAL.
  297. rv_std_cond_syntax = rv_std_cond_syntax && ` AND manst = '` && iv_manst && `'`.
  298. ENDIF.
  299.  
  300. ENDMETHOD.
  301.  
  302.  
  303. * <SIGNATURE>---------------------------------------------------------------------------------------+
  304. * | Instance Private Method ZCL_VM_BSEG->LOG_BSEG_CHANGES
  305. * +-------------------------------------------------------------------------------------------------+
  306. * | [--->] IS_BSEG TYPE TY_SHORT_BSEG
  307. * | [--->] IT_ACCCHG TYPE FDM_T_ACCCHG
  308. * +--------------------------------------------------------------------------------------</SIGNATURE>
  309. METHOD log_bseg_changes.
  310.  
  311. DATA ls_bseg_log TYPE zst_bseg_log.
  312.  
  313. SELECT MAX( logid ) FROM zst_bseg_log INTO ls_bseg_log-logid.
  314. IF sy-subrc NE 0.
  315. ls_bseg_log-logid = 1.
  316. ENDIF.
  317.  
  318. LOOP AT it_accchg INTO DATA(ls_accchg).
  319.  
  320. ls_bseg_log-logid = ls_bseg_log-logid + 1 .
  321.  
  322. ls_bseg_log-fdname = ls_accchg-fdname.
  323. ls_bseg_log-oldval = ls_accchg-oldval.
  324. ls_bseg_log-newval = ls_accchg-newval.
  325. ls_bseg_log-bukrs = is_bseg-bukrs.
  326. ls_bseg_log-belnr = is_bseg-belnr.
  327. ls_bseg_log-gjahr = is_bseg-gjahr.
  328. ls_bseg_log-edat = sy-datum.
  329. ls_bseg_log-ename = sy-uname.
  330. ls_bseg_log-etime = sy-uzeit.
  331.  
  332. INSERT INTO zst_bseg_log VALUES ls_bseg_log.
  333.  
  334. ENDLOOP.
  335.  
  336. ENDMETHOD.
  337.  
  338.  
  339. * <SIGNATURE>---------------------------------------------------------------------------------------+
  340. * | Static Private Method ZCL_VM_BSEG=>SELECT_VIA_VBFA
  341. * +-------------------------------------------------------------------------------------------------+
  342. * | [--->] IT_KDAUF_LIST TYPE TT_VBELN
  343. * | [--->] IV_KDAUF TYPE KDAUF
  344. * | [--->] IV_BUKRS TYPE BUKRS
  345. * | [--->] IRT_MANSP TYPE TY_MANSP_RANGE_TAB
  346. * | [--->] IV_STD_COND_SYNTAX TYPE STRING
  347. * | [<-()] RT_BSEG TYPE TY_SHORT_BSEG_TAB
  348. * +--------------------------------------------------------------------------------------</SIGNATURE>
  349. METHOD select_via_vbfa.
  350.  
  351. DATA: lt_kdauf TYPE tt_vbeln,
  352. lt_vbfa TYPE TABLE OF vbfa,
  353. lv_cond_syntax TYPE string.
  354.  
  355. get_param_list( EXPORTING it_table = it_kdauf_list iv_param = iv_kdauf
  356. IMPORTING et_list = lt_kdauf ).
  357.  
  358. CHECK lt_kdauf IS NOT INITIAL.
  359.  
  360. SELECT * FROM vbfa INTO TABLE lt_vbfa
  361. FOR ALL ENTRIES IN lt_kdauf
  362. WHERE vbelv = lt_kdauf-table_line.
  363.  
  364. CHECK lt_vbfa IS NOT INITIAL.
  365.  
  366. IF iv_bukrs IS NOT INITIAL.
  367. lv_cond_syntax = `bukrs = '` && iv_bukrs && `' AND `.
  368. ENDIF.
  369.  
  370. lv_cond_syntax = lv_cond_syntax && `belnr = lt_vbfa-vbeln` && iv_std_cond_syntax.
  371.  
  372. SELECT bukrs belnr gjahr buzei augbl bschl pswbt pswsl zuonr vbeln kunnr zfbdt mansp madat manst maber matnr FROM bseg
  373. INTO TABLE rt_bseg
  374. FOR ALL ENTRIES IN lt_vbfa
  375. WHERE (lv_cond_syntax).
  376.  
  377. ENDMETHOD.
  378.  
  379.  
  380. * <SIGNATURE>---------------------------------------------------------------------------------------+
  381. * | Static Private Method ZCL_VM_BSEG=>SELECT_WITH_ALL_SLIPS
  382. * +-------------------------------------------------------------------------------------------------+
  383. * | [--->] IT_BUKRS_KDAUF_LIST TYPE TY_ALL_SLIPS_TAB
  384. * | [--->] IV_KDAUF TYPE KDAUF
  385. * | [--->] IV_BUKRS TYPE BUKRS
  386. * | [--->] IRT_MANSP TYPE TY_MANSP_RANGE_TAB
  387. * | [--->] IV_STD_COND_SYNTAX TYPE STRING
  388. * | [<-()] RT_BSEG TYPE TY_SHORT_BSEG_TAB
  389. * +--------------------------------------------------------------------------------------</SIGNATURE>
  390. METHOD select_with_all_slips.
  391.  
  392. DATA: lt_bukrs_kdauf_list TYPE ty_all_slips_tab,
  393. lt_full_list TYPE ty_all_slips_tab,
  394. lv_cond_syntax TYPE string.
  395.  
  396. IF it_bukrs_kdauf_list IS NOT INITIAL.
  397. lt_bukrs_kdauf_list = it_bukrs_kdauf_list.
  398. ENDIF.
  399.  
  400. IF iv_kdauf IS NOT INITIAL AND iv_bukrs IS NOT INITIAL.
  401. APPEND INITIAL LINE TO lt_bukrs_kdauf_list ASSIGNING FIELD-SYMBOL(<bukrs_kdauf>).
  402. <bukrs_kdauf>-bukrs = iv_bukrs.
  403. <bukrs_kdauf>-kdauf = iv_kdauf.
  404. ENDIF.
  405.  
  406. LOOP AT lt_bukrs_kdauf_list ASSIGNING <bukrs_kdauf>.
  407. SELECT vbelv AS kdauf vbeln AS belnr FROM vbfa
  408. APPENDING CORRESPONDING FIELDS OF TABLE lt_full_list
  409. WHERE vbelv = <bukrs_kdauf>-kdauf.
  410. LOOP AT lt_full_list ASSIGNING FIELD-SYMBOL(<full_list>)
  411. WHERE bukrs IS INITIAL.
  412. <full_list>-bukrs = <bukrs_kdauf>-bukrs.
  413. ENDLOOP.
  414. ENDLOOP.
  415.  
  416. CHECK lt_full_list IS NOT INITIAL.
  417.  
  418. SORT lt_full_list BY bukrs belnr ASCENDING.
  419. DELETE ADJACENT DUPLICATES FROM lt_full_list COMPARING bukrs belnr.
  420.  
  421. lv_cond_syntax = `bukrs = lt_full_list-bukrs AND belnr = lt_full_list-belnr ` && iv_std_cond_syntax.
  422.  
  423. SELECT bukrs belnr gjahr buzei augbl bschl pswbt pswsl zuonr vbeln kunnr zfbdt mansp madat manst maber matnr FROM bseg
  424. INTO TABLE rt_bseg
  425. FOR ALL ENTRIES IN lt_full_list
  426. WHERE (lv_cond_syntax).
  427.  
  428. ENDMETHOD.
  429.  
  430.  
  431. * <SIGNATURE>---------------------------------------------------------------------------------------+
  432. * | Static Private Method ZCL_VM_BSEG=>SELECT_WITH_BUKRS_LIST
  433. * +-------------------------------------------------------------------------------------------------+
  434. * | [--->] IT_BUKRS_LIST TYPE T_BUKRS
  435. * | [--->] IV_BUKRS TYPE BUKRS
  436. * | [--->] IRT_MANSP TYPE TY_MANSP_RANGE_TAB
  437. * | [--->] IV_STD_COND_SYNTAX TYPE STRING
  438. * | [<-()] RT_BSEG TYPE TY_SHORT_BSEG_TAB
  439. * +--------------------------------------------------------------------------------------</SIGNATURE>
  440. METHOD select_with_bukrs_list.
  441.  
  442. DATA: lt_bukrs TYPE t_bukrs,
  443. lv_cond_syntax TYPE string.
  444.  
  445. get_param_list( EXPORTING it_table = it_bukrs_list iv_param = iv_bukrs
  446. IMPORTING et_list = lt_bukrs ).
  447.  
  448. CHECK lt_bukrs IS NOT INITIAL.
  449.  
  450. lv_cond_syntax = `bukrs = lt_bukrs-table_line` && iv_std_cond_syntax.
  451.  
  452. SELECT bukrs belnr gjahr buzei augbl bschl pswbt pswsl zuonr vbeln kunnr zfbdt mansp madat manst maber matnr FROM bseg
  453. INTO TABLE rt_bseg
  454. FOR ALL ENTRIES IN lt_bukrs
  455. WHERE (lv_cond_syntax).
  456.  
  457. ENDMETHOD.
  458.  
  459.  
  460. * <SIGNATURE>---------------------------------------------------------------------------------------+
  461. * | Instance Public Method ZCL_VM_BSEG->UPDATE_BSEG
  462. * +-------------------------------------------------------------------------------------------------+
  463. * | [--->] IT_BSEG TYPE TY_SHORT_BSEG_TAB(optional)
  464. * | [--->] IV_NEW_MABER TYPE MABER(optional)
  465. * | [--->] IV_NEW_MANSP TYPE MANSP(optional)
  466. * | [--->] IV_NEW_MANST TYPE MAHNS_D(optional)
  467. * | [--->] IV_NEW_MADAT TYPE MADAT(optional)
  468. * | [--->] IV_NEW_ZFBDT TYPE DZFBDT(optional)
  469. * | [EXC!] UPDATE_ERROR
  470. * +--------------------------------------------------------------------------------------</SIGNATURE>
  471. METHOD update_bseg.
  472.  
  473. DATA: lt_bseg TYPE ty_short_bseg_tab,
  474. lt_accchg TYPE TABLE OF accchg,
  475. ls_accchg TYPE accchg,
  476. ls_bseg TYPE ty_short_bseg,
  477. lv_error_msg TYPE string.
  478.  
  479. CHECK iv_new_maber IS SUPPLIED
  480. OR iv_new_mansp IS SUPPLIED
  481. OR iv_new_manst IS SUPPLIED
  482. OR iv_new_madat IS SUPPLIED
  483. OR iv_new_zfbdt IS SUPPLIED.
  484.  
  485. IF it_bseg IS SUPPLIED.
  486. lt_bseg = it_bseg.
  487. ELSE.
  488. lt_bseg = gt_bseg.
  489. ENDIF.
  490.  
  491. LOOP AT lt_bseg INTO ls_bseg.
  492. CLEAR lt_accchg.
  493. append_ maber.
  494. append_ mansp.
  495. append_ manst.
  496. append_ madat.
  497. append_ zfbdt.
  498.  
  499. fi_document_change( EXPORTING is_bseg = ls_bseg it_accchg = lt_accchg
  500. EXCEPTIONS update_error = 1 ).
  501.  
  502. IF sy-subrc IS INITIAL.
  503. log_bseg_changes( is_bseg = ls_bseg it_accchg = lt_accchg ).
  504. update_documents( is_bseg = ls_bseg
  505. it_accchg = lt_accchg ).
  506. ELSE.
  507. RAISE update_error.
  508. ENDIF.
  509. ENDLOOP.
  510.  
  511.  
  512.  
  513. ENDMETHOD.
  514.  
  515.  
  516. * <SIGNATURE>---------------------------------------------------------------------------------------+
  517. * | Instance Private Method ZCL_VM_BSEG->UPDATE_DOCUMENTS
  518. * +-------------------------------------------------------------------------------------------------+
  519. * | [--->] IS_BSEG TYPE TY_SHORT_BSEG(optional)
  520. * | [--->] IT_ACCCHG TYPE TY_ACCCHG_TAB(optional)
  521. * +--------------------------------------------------------------------------------------</SIGNATURE>
  522. METHOD UPDATE_DOCUMENTS.
  523.  
  524. DATA: lv_obj_id TYPE cdhdr-objectid,
  525. ls_cd_bseg TYPE fbseg,
  526. ls_bseg TYPE bseg,
  527. ybseg TYPE TABLE OF fbseg,
  528. xbseg TYPE TABLE OF fbseg.
  529.  
  530. * Dummy structures for change document update function
  531. DATA: ls_bkdf TYPE bkdf,
  532. ls_bkpf TYPE bkpf,
  533. lt_bsed TYPE TABLE OF fbsed,
  534. lt_bsec TYPE TABLE OF fbsec,
  535. lt_bseg_add TYPE TABLE OF fbseg_add,
  536. lt_bset TYPE TABLE OF fbset.
  537.  
  538.  
  539. SELECT SINGLE * FROM bseg
  540. INTO ls_bseg
  541. WHERE bukrs = is_bseg-bukrs
  542. AND belnr = is_bseg-belnr
  543. AND gjahr = is_bseg-gjahr
  544. AND buzei = is_bseg-buzei.
  545. IF sy-subrc = 0.
  546. MOVE-CORRESPONDING ls_bseg TO ls_cd_bseg.
  547. APPEND ls_cd_bseg TO xbseg.
  548. LOOP AT it_accchg INTO DATA(ls_accchg).
  549. CASE ls_accchg-fdname.
  550. WHEN 'MABER'.
  551. ls_cd_bseg-maber = ls_accchg-newval .
  552. WHEN 'MANSP'.
  553. ls_cd_bseg-mansp = ls_accchg-newval .
  554. WHEN 'MANST'.
  555. ls_cd_bseg-manst = ls_accchg-newval.
  556. WHEN 'MADAT'.
  557. ls_cd_bseg-madat = ls_accchg-newval .
  558. WHEN 'ZFBDT'.
  559. ls_cd_bseg-zfbdt = ls_accchg-newval.
  560. ENDCASE.
  561. ENDLOOP.
  562.  
  563. APPEND ls_cd_bseg TO ybseg.
  564.  
  565. lv_obj_id+0(3) = sy-mandt.
  566. lv_obj_id+3(4) = is_bseg-bukrs.
  567. lv_obj_id+7(10) = is_bseg-belnr.
  568. lv_obj_id+17(4) = is_bseg-gjahr.
  569. ENDIF.
  570.  
  571. CHECK NOT lv_obj_id IS INITIAL.
  572.  
  573. * Write change document
  574. CALL FUNCTION 'BELEG_WRITE_DOCUMENT'
  575. EXPORTING
  576. objectid = lv_obj_id
  577. tcode = 'VORF'
  578. utime = sy-uzeit
  579. udate = sy-datum
  580. username = sy-uname
  581. n_bkdf = ls_bkdf
  582. o_bkdf = ls_bkdf
  583. upd_bkdf = ' '
  584. n_bkpf = ls_bkpf
  585. o_bkpf = ls_bkpf
  586. upd_bkpf = ' '
  587. upd_bsec = ' '
  588. upd_bsed = ' '
  589. upd_bseg = 'U'
  590. upd_bseg_add = ' '
  591. upd_bset = ' '
  592. TABLES
  593. xbsec = lt_bsec
  594. ybsec = lt_bsec
  595. xbsed = lt_bsed
  596. ybsed = lt_bsed
  597. xbseg = xbseg
  598. ybseg = ybseg
  599. xbseg_add = lt_bseg_add
  600. ybseg_add = lt_bseg_add
  601. xbset = lt_bset
  602. ybset = lt_bset.
  603.  
  604. ENDMETHOD.
  605. ENDCLASS.

Report this snippet  

You need to login to post a comment.