Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 5.21 KB | None | 0 0
  1.   DATA : order_header_in LIKE bapisdhd1.
  2.   DATA : order_items_in LIKE bapisditm OCCURS 0 WITH HEADER LINE.
  3.   DATA : return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
  4.   DATA : order_partners LIKE bapiparnr OCCURS 0 WITH HEADER LINE.
  5.   DATA : order_keys LIKE bapisdkey OCCURS 0 WITH HEADER LINE.
  6.   DATA : order_schedules_in LIKE bapischdl OCCURS 0 WITH HEADER LINE.
  7.   DATA : salesdocument LIKE  bapivbeln-vbeln.
  8.   DATA : lv_vkont TYPE vkont_kk.
  9.   DATA : lt_bapisdtext LIKE bapisdtext OCCURS 0 WITH HEADER LINE.
  10.   DATA : ls_line TYPE tline.
  11.  
  12.  
  13.  
  14. * Start of HDDK901840 - HEP_WM_PM_00019 Unauthorised Consumption
  15.  
  16.   IF NOT ls_uc-non_std_service_fee IS INITIAL AND
  17.          gs_uc_type-non_std_fee_rel IS INITIAL.
  18.  
  19.     CLEAR lv_vkont.
  20.  
  21.     SELECT SINGLE vkonto FROM ever INTO lv_vkont
  22.                         WHERE anlage = ls_uc-anlage.
  23.  
  24.     IF sy-subrc EQ 0.
  25.       order_header_in-fkk_conacct =  lv_vkont.
  26.     ENDIF.
  27.  
  28.     "fill header
  29.     order_header_in-doc_type = 'ZNAP'.
  30.     order_header_in-sales_org = '0031'.
  31.     order_header_in-distr_chan = '10'.
  32.     order_header_in-purch_date = sy-datum.
  33.     order_header_in-division  = '10'.
  34.  
  35. ***UC-A
  36.     "fill items
  37.     order_items_in-itm_number = 10.
  38.     order_items_in-material = ls_uc-non_std_service_fee_matnr.
  39.     order_items_in-plant      = ls_uc-plant.
  40.  
  41.  
  42.     APPEND order_items_in.
  43.  
  44.     "fill qty
  45.     order_schedules_in-itm_number = 10.
  46.     order_schedules_in-req_qty = 1.
  47.     APPEND order_schedules_in.
  48.  
  49.  
  50.     "set partner
  51.     order_partners-partn_role = 'AG'.
  52.     order_partners-partn_numb = ls_uc-kunnr.
  53.     APPEND order_partners.
  54.  
  55.     LOOP AT gt_line INTO ls_line.
  56.  
  57.       lt_bapisdtext-text_id   = '0001'.
  58.       lt_bapisdtext-langu     = sy-langu.
  59.       lt_bapisdtext-text_line = ls_line-tdline.
  60.       lt_bapisdtext-format_col = ls_line-tdformat.
  61.  
  62.       APPEND lt_bapisdtext.
  63.  
  64.     ENDLOOP.
  65.  
  66.   ELSE.
  67.  
  68. * End of HDDK901840 - HEP_WM_PM_00019 Unauthorised Consumption
  69.  
  70.     CLEAR lv_vkont.
  71.  
  72.     SELECT SINGLE vkonto FROM ever INTO lv_vkont
  73.                         WHERE anlage = ls_uc-anlage.
  74.  
  75.     IF sy-subrc EQ 0.
  76.       order_header_in-fkk_conacct =  lv_vkont.
  77.     ENDIF.
  78.  
  79.     "fill header
  80.     order_header_in-doc_type = 'ZNAP'.
  81.     order_header_in-sales_org = '0100'.
  82.     order_header_in-distr_chan = '10'.
  83.     order_header_in-purch_date = sy-datum.
  84.     order_header_in-division  = '01'.
  85.  
  86. ***UC-A
  87.     "fill items
  88.     order_items_in-itm_number = 10.
  89.     order_items_in-material = 'ZWM=_____UC-A'.
  90.     order_items_in-plant      = ls_uc-plant.
  91.     APPEND order_items_in.
  92.  
  93.     "fill qty
  94.     order_schedules_in-itm_number = 10.
  95.     order_schedules_in-req_qty = ls_uc-amp.
  96.     APPEND order_schedules_in.
  97.  
  98. ***UC-HOURS
  99.     "fill items
  100.     order_items_in-itm_number = 20.
  101.     order_items_in-material = 'ZWM=_UC-HOURS'.
  102.     order_items_in-plant      = ls_uc-plant.
  103.     APPEND order_items_in.
  104.  
  105.     "fill qty
  106.     order_schedules_in-itm_number = 20.
  107.     order_schedules_in-req_qty = ls_uc-tot_hours.
  108.     APPEND order_schedules_in.
  109.  
  110. ***UC-KWH
  111.     "fill items
  112.     order_items_in-itm_number = 30.
  113.     order_items_in-material = 'ZWM=___UC-KWH'.
  114.     order_items_in-plant      = ls_uc-plant.
  115.     APPEND order_items_in.
  116.  
  117.     "fill qty
  118.     order_schedules_in-itm_number = 30.
  119.     order_schedules_in-req_qty = ls_uc-consump.
  120.     APPEND order_schedules_in.
  121.  
  122.  
  123. ***UC-V
  124.     "fill items
  125.     order_items_in-itm_number = 40.
  126.     order_items_in-material = 'ZWM=_____UC-V'.
  127.     order_items_in-plant      = ls_uc-plant.
  128.     APPEND order_items_in.
  129.  
  130.  
  131. * start of HDDK901840 - HEP_WM_PM_00019 Unauthorised Consumption
  132.  
  133.     "fill qty
  134.     order_schedules_in-itm_number = 40.
  135.     order_schedules_in-req_qty = ls_uc-voltage.
  136.     APPEND order_schedules_in.
  137.  
  138. **Non Std Service Fee for ALL Other
  139. *    "fill items
  140.  
  141.     IF NOT gs_uc_type-non_std_fee_matnr IS INITIAL.
  142.       order_items_in-itm_number = 50.
  143.       order_items_in-material = gs_uc_type-non_std_fee_matnr.
  144.       order_items_in-plant      = ls_uc-plant.
  145.       APPEND order_items_in.
  146.  
  147.       "fill qty
  148.       order_schedules_in-itm_number = 50.
  149.       order_schedules_in-req_qty = ls_uc-non_std_service_fee.
  150.       APPEND order_schedules_in.
  151.  
  152.     ENDIF.
  153.  
  154. * end of HDDK901840 - HEP_WM_PM_00019 Unauthorised Consumption
  155.  
  156.     "set partner
  157.     order_partners-partn_role = 'AG'.
  158.     order_partners-partn_numb = ls_uc-kunnr.
  159.     APPEND order_partners.
  160.  
  161. * start of HDDK901840 - HEP_WM_PM_00019 Unauthorised Consumption
  162.  
  163.     LOOP AT gt_line INTO ls_line.
  164.  
  165.       lt_bapisdtext-text_id   = '0001'.
  166.       lt_bapisdtext-langu     = sy-langu.
  167.       lt_bapisdtext-text_line = ls_line-tdline.
  168.       lt_bapisdtext-format_col = ls_line-tdformat.
  169.  
  170.       APPEND lt_bapisdtext.
  171.  
  172.     ENDLOOP.
  173.     APPEND lt_bapisdtext.
  174.  
  175. * end of HDDK901840 - HEP_WM_PM_00019 Unauthorised Consumption
  176.  
  177.   ENDIF.
  178.  
  179.  
  180.  
  181.   CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
  182.     EXPORTING
  183.       order_header_in    = order_header_in
  184.     IMPORTING
  185.       salesdocument      = salesdocument
  186.     TABLES
  187.       return             = return
  188.       order_items_in     = order_items_in
  189.       order_partners     = order_partners
  190.       order_schedules_in = order_schedules_in
  191.       order_keys         = order_keys
  192.       order_text         = lt_bapisdtext.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement