Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.05 KB | None | 0 0
  1. *&---------------------------------------------------------------------*
  2. *& Report ZSHIPCSH
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *& http://10.1.212.34:8010/sap/bc/zshippost?sap-client=14&pgmna=zshipcsh
  6. *&
  7. *&---------------------------------------------------------------------*
  8. REPORT ZSHIPCSH.
  9.  
  10. INCLUDE zin_list_header.
  11. INCLUDE zin_alv_common.
  12.  
  13. DATA: headerdeadline LIKE bapishipmentheaderdeadline OCCURS 0 WITH HEADER LINE,
  14. headerdata LIKE bapishipmentheader,
  15. return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
  16. itemdata LIKE bapishipmentitem OCCURS 0 WITH HEADER LINE,
  17. stagedata LIKE bapishipmentstage OCCURS 0 WITH HEADER LINE,
  18. stagedeadline LIKE bapishipmentstagedeadline OCCURS 0 WITH HEADER LINE,
  19. itemonstage LIKE bapishipmentitemonstage OCCURS 0 WITH HEADER LINE,
  20. address LIKE bapishipmentaddress OCCURS 0 WITH HEADER LINE,
  21. hdunheader LIKE bapishipmenthdunheader OCCURS 0 WITH HEADER LINE,
  22. hdunitem LIKE bapishipmenthdunitem OCCURS 0 WITH HEADER LINE,
  23. TRANSPORT LIKE BAPISHIPMENTIDS-SHIPMENTNUM,
  24. SHIPMENTGUID LIKE BAPISHIPMENTIDS-GUID.
  25.  
  26. DATA :
  27. bdc_data LIKE bdcdata OCCURS 0 WITH HEADER LINE,
  28. bdc_message LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
  29. wa_message LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
  30. opt TYPE ctu_params.
  31.  
  32. types :
  33. BEGIN OF zs_msg,
  34. msg type c LENGTH 100,
  35. shi TYPE BAPISHIPMENTIDS-SHIPMENTNUM,
  36. END OF zs_msg.
  37.  
  38. data :
  39. imp_stagedata LIKE bapishipmentstage OCCURS 0 WITH HEADER LINE,
  40. imp_headerdeadline LIKE bapishipmentheaderdeadline OCCURS 0 WITH HEADER LINE,
  41. imp_headerdata LIKE bapishipmentheader,
  42. it_print TYPE TABLE OF ztship01 WITH HEADER LINE,
  43. it_msg TYPE TABLE OF zs_msg,
  44. wa_msg TYPE zs_msg,
  45. it_hana TYPE TABLE OF zs_msg,
  46. lh_body type c LENGTH 260000.
  47.  
  48. parameter :
  49. p_var TYPE ztship01-cokey,
  50. p_sukey TYPE ztship01-sukey,
  51. p_vap TYPE ztship01-col01. "E - ecc, H - hana
  52.  
  53. START-OF-SELECTION.
  54.  
  55. PERFORM getdata.
  56. if it_print[] is NOT INITIAL.
  57. * READ TABLE it_print WITH KEY colid = 'H'.
  58. * p_vap = it_print-col12.
  59. * if p_vap is INITIAL.
  60. * p_vap = 'E'.
  61. * endif.
  62. * "temporer to point hana
  63.  
  64. READ TABLE it_print WITH KEY colid = 'I'.
  65. p_vap = it_print-col01.
  66. if p_vap cp '922*'.
  67. p_vap = 'H'.
  68. else.
  69. p_vap = 'E'.
  70. endif.
  71.  
  72. if p_vap = 'H'.
  73. "---- hana
  74. PERFORM cbody.
  75. PERFORM insert.
  76. PERFORM joindata.
  77. "---- hana
  78. elseif p_vap = 'E'.
  79. * PERFORM converting.
  80. PERFORM changeroute.
  81. PERFORM converting2.
  82. endif.
  83. else.
  84. data :
  85. lh_col16 TYPE ztship01-col16.
  86. CLEAR : lh_col16.
  87. select SINGLE col16
  88. from ztship01
  89. INTO lh_col16
  90. WHERE cokey = p_var AND sukey = p_sukey.
  91.  
  92. if sy-subrc = 0.
  93. wa_msg-msg = 'Shipment already created'.
  94. wa_msg-shi = lh_col16.
  95. else.
  96. wa_msg-msg = 'Error : Booking not Found'.
  97. wa_msg-shi = ''.
  98. endif.
  99. APPEND wa_msg to it_msg.
  100. endif.
  101.  
  102. * wa_msg-msg = p_var && p_sukey.
  103. * APPEND wa_msg to it_msg.
  104.  
  105.  
  106. PERFORM showalv TABLES it_msg.
  107.  
  108. end-of-SELECTION.
  109.  
  110. """""""""""""" ALV start
  111.  
  112. *&---------------------------------------------------------------------*
  113. *& Form SHOWALV
  114. *&---------------------------------------------------------------------*
  115. * text
  116. *----------------------------------------------------------------------*
  117. * --> p1 text
  118. * <-- p2 text
  119. *----------------------------------------------------------------------*
  120. FORM showalv TABLES ft_report .
  121.  
  122. DATA :
  123. gt_fc TYPE lvc_t_fcat,
  124. g_layo TYPE lvc_s_layo.
  125. g_layo-stylefname = 'CELLTAB'.
  126.  
  127. PERFORM fm_gui_message USING 'Generating report ...' ''.
  128. PERFORM fm_clear_alv_data.
  129. PERFORM fm_build_fieldcat TABLES ft_report.
  130. PERFORM fm_build_layout USING d_layout.
  131. PERFORM fm_build_sortfield USING t_alv_isort[].
  132. PERFORM fm_build_event TABLES t_alv_event[].
  133. PERFORM fm_build_event_exit.
  134. PERFORM fm_build_print USING d_print.
  135.  
  136. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' " 'REUSE_ALV_LIST_DISPLAY'
  137. EXPORTING
  138. i_callback_program = d_repid
  139. is_layout = d_layout
  140. it_fieldcat = t_alv_fieldcat[]
  141. it_sort = t_alv_isort[]
  142. i_default = 'X'
  143. i_save = 'A'
  144. is_variant = d_alv_variant
  145. it_events = t_alv_event[]
  146. it_event_exit = t_event_exit[]
  147. is_print = d_print
  148. TABLES
  149. t_outtab = ft_report
  150. EXCEPTIONS
  151. program_error = 1
  152. OTHERS = 2.
  153. IF sy-subrc <> 0.
  154. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  155. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  156. ENDIF.
  157. ENDFORM.
  158.  
  159. FORM fm_build_fieldcat TABLES ft_report.
  160.  
  161. REFRESH: t_alv_fieldcat.
  162. PERFORM f_fieldcatg USING ft_report:
  163. 'MSG' '' '' '' '' 'Messages' '' '' '' '' '' '' '' '' '' '',
  164. 'SHI' '' '' '' '' 'Shipment No.' '' '' '' '' '' '' '' '' '' ''.
  165.  
  166. ENDFORM.
  167.  
  168. FORM fm_top_of_page.
  169. PERFORM fm_hdr_uline.
  170. PERFORM fm_hdr_title USING sy-title.
  171. PERFORM fm_skip.
  172. PERFORM fm_hdr_uline.
  173. ENDFORM. "
  174.  
  175. FORM fm_end_of_page.
  176. ENDFORM.
  177.  
  178. FORM fm_refresh_intab.
  179. * refresh:
  180. * it_zvend.
  181. ENDFORM.
  182.  
  183.  
  184. FORM fm_gui_message USING fu_text1 fu_text2.
  185. DATA: ld_text1(100) TYPE c.
  186.  
  187. CONCATENATE fu_text1 fu_text2 INTO ld_text1
  188. SEPARATED BY space.
  189. CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
  190. EXPORTING
  191. percentage = 0
  192. text = ld_text1.
  193. ENDFORM.
  194.  
  195. FORM fm_clear_alv_data.
  196. CLEAR:t_alv_fieldcat,
  197. t_alv_event,
  198. t_events,
  199. t_alv_isort,
  200. t_alv_filter,
  201. t_event_exit,
  202. d_alv_isort,
  203. d_alv_variant,
  204. d_alv_list_scroll,
  205. d_alv_sort_postn,
  206. d_alv_keyinfo,
  207. d_alv_fieldcat,
  208. d_alv_formname,
  209. d_alv_ucomm,
  210. d_alv_print,
  211. d_alv_repid,
  212. d_alv_tabix,
  213. d_alv_subrc,
  214. d_alv_screen_start_column,
  215. d_alv_screen_start_line,
  216. d_alv_screen_end_column,
  217. d_alv_screen_end_line,
  218. d_alv_layout,
  219. d_layout,
  220. d_repid,
  221. d_print.
  222.  
  223. REFRESH: t_alv_fieldcat,
  224. t_alv_event,
  225. t_events,
  226. t_alv_isort,
  227. t_alv_filter,
  228. t_event_exit.
  229.  
  230. d_repid = sy-repid.
  231. ENDFORM.
  232.  
  233. FORM fm_build_layout USING fu_layout TYPE slis_layout_alv.
  234. fu_layout-colwidth_optimize = 'X'.
  235. fu_layout-no_colhead = space.
  236. fu_layout-group_change_edit = 'X'.
  237. " fu_layout-info_fieldname = 'LINE_COLOR'.
  238. "fu_layout-info_fieldname = 'color'.
  239. "
  240. ENDFORM.
  241.  
  242. FORM fm_build_sortfield USING fu_sort TYPE slis_t_sortinfo_alv.
  243. DATA: ld_sort TYPE slis_sortinfo_alv.
  244. ENDFORM.
  245.  
  246. FORM fm_build_event TABLES ft_events LIKE t_events.
  247. REFRESH: ft_events.
  248. CLEAR ft_events.
  249. ft_events-name = slis_ev_top_of_page.
  250. ft_events-form = 'FM_TOP_OF_PAGE'.
  251. APPEND ft_events.
  252.  
  253. CLEAR ft_events.
  254. ft_events-name = slis_ev_end_of_list.
  255. ft_events-form = 'FM_END_OF_PAGE'.
  256. APPEND ft_events.
  257. ENDFORM.
  258.  
  259. FORM fm_build_event_exit.
  260. CLEAR t_event_exit.
  261. t_event_exit-ucomm = '&OUP'.
  262. t_event_exit-after = 'X'.
  263. APPEND t_event_exit.
  264.  
  265. CLEAR t_event_exit.
  266. t_event_exit-ucomm = '&ODN'.
  267. t_event_exit-after = 'X'.
  268. APPEND t_event_exit.
  269. ENDFORM.
  270.  
  271. FORM fm_build_print USING fu_print TYPE slis_print_alv.
  272. fu_print-no_print_listinfos = 'X'.
  273. fu_print-no_print_selinfos = 'X'.
  274. fu_print-no_coverpage = 'X'.
  275. fu_print-no_print_hierseq_item = 'X'.
  276. ENDFORM.
  277.  
  278. FORM f_fieldcatg USING VALUE(fu_types)
  279. VALUE(fu_fname) " internal table
  280. VALUE(fu_reftb)
  281. VALUE(fu_refld)
  282. VALUE(fu_noout)
  283. VALUE(fu_outln)
  284. VALUE(fu_fltxt)
  285. VALUE(fu_dosum)
  286. VALUE(fu_hotsp)
  287. VALUE(fu_dec)
  288. VALUE(fu_waers)
  289. VALUE(fu_meins)
  290. VALUE(fu_waers_f)
  291. VALUE(fu_meins_f)
  292. VALUE(fu_checkbox)
  293. VALUE(fu_fixcolumn)
  294. VALUE(fu_key).
  295.  
  296. DATA: ld_fieldcat TYPE slis_fieldcat_alv.
  297. CLEAR: ld_fieldcat.
  298.  
  299. ld_fieldcat-tabname = fu_types.
  300. ld_fieldcat-fieldname = fu_fname.
  301. ld_fieldcat-ref_tabname = fu_reftb.
  302. ld_fieldcat-ref_fieldname = fu_refld.
  303. ld_fieldcat-no_out = fu_noout.
  304. ld_fieldcat-outputlen = fu_outln.
  305. ld_fieldcat-seltext_l = fu_fltxt.
  306. ld_fieldcat-seltext_m = fu_fltxt.
  307. ld_fieldcat-seltext_s = fu_fltxt.
  308. ld_fieldcat-reptext_ddic = fu_fltxt.
  309. ld_fieldcat-no_out = fu_noout.
  310. ld_fieldcat-do_sum = fu_dosum.
  311. ld_fieldcat-hotspot = fu_hotsp.
  312. ld_fieldcat-decimals_out = fu_dec.
  313. ld_fieldcat-currency = fu_waers.
  314. ld_fieldcat-quantity = fu_meins.
  315. ld_fieldcat-qfieldname = fu_meins_f.
  316. ld_fieldcat-cfieldname = fu_waers_f.
  317. ld_fieldcat-checkbox = fu_checkbox.
  318. ld_fieldcat-fix_column = fu_fixcolumn.
  319. ld_fieldcat-key = fu_key.
  320.  
  321. APPEND ld_fieldcat TO t_alv_fieldcat.
  322. CLEAR ld_fieldcat.
  323. ENDFORM. " f_fieldcatg
  324.  
  325. FORM header_build USING lt_top_of_page TYPE
  326. slis_t_listheader.
  327.  
  328. TABLES: t001w, t001k.
  329.  
  330. DATA: ls_line TYPE slis_listheader,
  331. gltrpl(10), gltrph(10),
  332. print_tm(8), name1 LIKE t001w-name1.
  333.  
  334. CLEAR ls_line.
  335. ls_line-typ = 'H'.
  336. ls_line-info = sy-title.
  337. APPEND ls_line TO lt_top_of_page.
  338.  
  339. CLEAR ls_line.
  340. ls_line-typ = 'H'.
  341. ls_line-info = 'Print date:'.
  342. CONCATENATE ls_line-info sy-datum+6(2) sy-datum+4(2) sy-datum(4)
  343. INTO ls_line-info
  344. SEPARATED BY space.
  345. APPEND ls_line TO lt_top_of_page.
  346.  
  347. CLEAR ls_line.
  348. ls_line-typ = 'H'.
  349. ls_line-info = 'Print time: '.
  350. WRITE sy-uzeit TO print_tm USING EDIT MASK '__:__:__'.
  351. CONCATENATE ls_line-info print_tm INTO ls_line-info
  352. SEPARATED BY space.
  353. APPEND ls_line TO lt_top_of_page.
  354.  
  355. CLEAR ls_line.
  356. ls_line-typ = 'H'.
  357. ls_line-info = 'User name:'.
  358. CONCATENATE ls_line-info sy-uname INTO ls_line-info
  359. SEPARATED BY space.
  360.  
  361. APPEND ls_line TO lt_top_of_page.
  362.  
  363. ENDFORM. "header_BUILD
  364. """""""""""""" end ALV
  365.  
  366. *&---------------------------------------------------------------------*
  367. *& Form GETDATA
  368. *&---------------------------------------------------------------------*
  369. * text
  370. *----------------------------------------------------------------------*
  371. * --> p1 text
  372. * <-- p2 text
  373. *----------------------------------------------------------------------*
  374. FORM getdata .
  375. select *
  376. from ztship01
  377. into CORRESPONDING FIELDS OF TABLE it_print
  378. WHERE cokey eq p_var AND sukey = p_sukey and col16 = ''.
  379. ENDFORM.
  380. *&---------------------------------------------------------------------*
  381. *& Form CONVERTING
  382. *&---------------------------------------------------------------------*
  383. * text
  384. *----------------------------------------------------------------------*
  385. * --> p1 text
  386. * <-- p2 text
  387. *----------------------------------------------------------------------*
  388. FORM converting .
  389. clear : headerdata.
  390.  
  391. LOOP AT it_print WHERE colid = 'H'.
  392. headerdata-shipment_type = it_print-col01.
  393. headerdata-trans_plan_pt = it_print-col02.
  394. headerdata-shipping_type = it_print-col03.
  395. headerdata-shipment_route = it_print-col04.
  396. headerdata-container_id = it_print-col05.
  397. headerdata-external_id_1 = it_print-col06.
  398. headerdata-external_id_2 = it_print-col07.
  399. headerdata-description = it_print-col08.
  400. headerdata-status_plan = it_print-col09.
  401. headerdata-TENDERING_CARRIER_TRACK_ID = it_print-col11.
  402. * headerdata-status_checkin = it_print-col10.
  403. * headerdata-status_load_start = it_print-col11.
  404. * headerdata-status_load_end = it_print-col12.
  405. * headerdata-status_compl = it_print-col13.
  406. * headerdata-status_shpmnt_start = it_print-col14.
  407. * headerdata-status_shpmnt_end = it_print-col15.
  408. headerdata-status_checkin = ''.
  409. headerdata-status_load_start = ''.
  410. headerdata-status_load_end = ''.
  411. headerdata-status_compl = ''.
  412. headerdata-status_shpmnt_start = ''.
  413. headerdata-status_shpmnt_end = ''.
  414.  
  415.  
  416. headerdata-service_agent_id = it_print-col10.
  417. ENDLOOP.
  418.  
  419. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  420. EXPORTING
  421. input = headerdata-service_agent_id
  422. IMPORTING
  423. output = headerdata-service_agent_id.
  424.  
  425. LOOP AT it_print WHERE colid = 'L'.
  426. headerdeadline-time_type = it_print-col01.
  427. headerdeadline-time_stamp_utc = it_print-col02.
  428. headerdeadline-time_zone = it_print-col03.
  429. APPEND headerdeadline.
  430. ENDLOOP.
  431.  
  432. LOOP AT it_print WHERE colid = 'I'.
  433. itemdata-DELIVERY = it_print-col01.
  434. append itemdata.
  435. ENDLOOP.
  436.  
  437. data :
  438. fwdag TYPE bapishipmentstage-SERVICE_AGENT.
  439.  
  440. LOOP AT it_print WHERE colid = 'S'.
  441. stagedata-stage_cat = it_print-col01.
  442. stagedata-stage_seq = it_print-col02.
  443. stagedata-shipping_type = it_print-col03.
  444. stagedata-leg_indicator = it_print-col04.
  445. stagedata-org_point = it_print-col05.
  446. stagedata-dest_point = it_print-col06.
  447. CLEAR : fwdag.
  448. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  449. EXPORTING
  450. input = it_print-col08
  451. IMPORTING
  452. output = fwdag.
  453. stagedata-service_agent = fwdag. "it_print-col08.
  454. * stagedata-shpmnt_cost_rel = it_print-col07.
  455. APPEND stagedata.
  456.  
  457. * itemonstage-STAGE_SEQ = it_print-col02.
  458. * itemonstage-DELIVERY = ''.
  459. * append itemonstage.
  460. ENDLOOP.
  461.  
  462.  
  463.  
  464. CALL FUNCTION 'BAPI_SHIPMENT_CREATE'
  465. EXPORTING
  466. headerdata = headerdata
  467. IMPORTING
  468. TRANSPORT = transport
  469. * SHIPMENTGUID =
  470. TABLES
  471. headerdeadline = headerdeadline
  472. itemdata = itemdata
  473. stagedata = stagedata
  474. stagedeadline = stagedeadline
  475. itemonstage = itemonstage
  476. address = address
  477. hdunheader = hdunheader
  478. hdunitem = hdunitem
  479. return = return.
  480.  
  481. if sy-subrc = 0.
  482.  
  483. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  484. EXPORTING
  485. wait = 'X'.
  486. endif.
  487.  
  488. if transport is INITIAL.
  489. LOOP AT return.
  490. wa_msg-msg = return-message.
  491. APPEND wa_msg to it_msg.
  492. ENDLOOP.
  493.  
  494. else.
  495. wa_msg-msg = 'Shipment Created'.
  496. wa_msg-shi = transport.
  497. APPEND wa_msg to it_msg.
  498. UPDATE ztship01
  499. SET col16 = transport
  500. WHERE cokey = p_var AND sukey = p_sukey.
  501. endif.
  502.  
  503.  
  504.  
  505. ENDFORM.
  506. *&---------------------------------------------------------------------*
  507. *& Form INSERT
  508. *&---------------------------------------------------------------------*
  509. * text
  510. *----------------------------------------------------------------------*
  511. * --> p1 text
  512. * <-- p2 text
  513. *----------------------------------------------------------------------*
  514. FORM insert .
  515.  
  516. data : lo_client TYPE REF TO if_http_client,
  517. lc_url TYPE string,
  518. lc_content TYPE string,
  519. lt_html TYPE TABLE OF string WITH HEADER LINE,
  520. lval TYPE string,
  521. fields TYPE tihttpnvp,
  522. lv_buzei type bsis-buzei,
  523. l_fields type tihttpnvp,
  524. iv_json_data type string,
  525. iv_json_data2 type string,
  526. wa_ZWEBSCAN001 type ZWEBSCAN001,
  527. w_fields like line of l_fields.
  528.  
  529.  
  530. * IF sy-sysid = 'NDV'.
  531. * lc_url = 'http://10.3.212.21:8000/sap/bc/zshippost'.
  532. * ELSEIF sy-sysid = 'NPR'.
  533. * lc_url = 'http://10.3.212.38:8000/sap/bc/zshippost'.
  534. * ELSEIF sy-sysid = 'NQA'.
  535. * lc_url = 'http://10.3.212.33:8000/sap/bc/zshippost'.
  536. * ENDIF.
  537.  
  538. IF sy-sysid = 'NDV'.
  539. lc_url = 'http://10.3.212.21:8000/sap/bc/zshippost'.
  540. w_fields-name = 'sap-client'.
  541. w_fields-value = '110'.
  542. APPEND w_fields TO l_fields.
  543. ELSEIF sy-sysid = 'NPR'.
  544. lc_url = 'http://10.3.212.38:8000/sap/bc/zshippost'.
  545. w_fields-name = 'sap-client'.
  546. w_fields-value = '300'.
  547. APPEND w_fields TO l_fields.
  548. ELSEIF sy-sysid = 'NQA'.
  549. w_fields-name = 'sap-client'.
  550. w_fields-value = '200'.
  551. APPEND w_fields TO l_fields.
  552. lc_url = 'http://10.3.212.33:8000/sap/bc/zshippost'.
  553. ENDIF.
  554.  
  555. CALL METHOD cl_http_client=>create_by_url
  556. EXPORTING
  557. url = lc_url
  558. IMPORTING
  559. client = lo_client
  560. EXCEPTIONS
  561. OTHERS = 1.
  562. IF sy-subrc IS NOT INITIAL.
  563. EXIT.
  564. ENDIF.
  565.  
  566. lo_client->request->set_header_field( name = '~request_method'
  567. value = 'POST' ).
  568.  
  569. "sap-client=140&pgmna=zeprocmat&p_type=g&p_form=a
  570.  
  571. * w_fields-name = 'sap-client'.
  572. * IF sy-mandt = '140'.
  573. * w_fields-value = '110'.
  574. * ELSE.
  575. * w_fields-value = '300'.
  576. * ENDIF.
  577. * APPEND w_fields to l_fields.
  578.  
  579. w_fields-name = 'pgmna'.
  580. w_fields-value = sy-cprog.
  581. APPEND w_fields to l_fields.
  582.  
  583. "iv_json_data = '[{"colid":"H","cokey":"A1","col01":"KP02","col02":"P300","col03":"Z3", "col04":"BDKU01","col05":"CONTAINER_ID","col06":"external_id_1","col07":"external_id_2","col08":"description","col09":"","col10":"400000"}]'.
  584. iv_json_data = lh_body.
  585. lo_client->request->set_cdata( iv_json_data ).
  586. lo_client->request->set_form_fields( fields = l_fields ).
  587.  
  588. lo_client->send( ).
  589. CALL METHOD lo_client->receive
  590. EXCEPTIONS
  591. http_communication_failure = 1
  592. http_invalid_state = 2
  593. http_processing_failed = 3
  594. OTHERS = 4.
  595. IF sy-subrc IS NOT INITIAL.
  596. EXIT.
  597. ENDIF.
  598.  
  599. CALL METHOD lo_client->response->get_header_fields
  600. CHANGING
  601. fields = fields.
  602.  
  603. lc_content = lo_client->response->get_cdata( ).
  604.  
  605. SPLIT lc_content AT cl_abap_char_utilities=>cr_lf INTO TABLE lt_html.
  606.  
  607. /ui2/cl_json=>deserialize(
  608. EXPORTING
  609. json = lc_content
  610. pretty_name = /ui2/cl_json=>pretty_mode-camel_case
  611. CHANGING
  612. data = it_hana ).
  613.  
  614. ENDFORM.
  615. *&---------------------------------------------------------------------*
  616. *& Form CBODY
  617. *&---------------------------------------------------------------------*
  618. * text
  619. *----------------------------------------------------------------------*
  620. * --> p1 text
  621. * <-- p2 text
  622. *----------------------------------------------------------------------*
  623. FORM cbody .
  624.  
  625. LOOP AT it_print WHERE colid = 'H'.
  626. lh_body = '[{'.
  627. lh_body = lh_body && '"colid":"' && it_print-colid && '",'.
  628. lh_body = lh_body && '"cokey":"' && it_print-cokey && '",'.
  629. lh_body = lh_body && '"sukey":"' && it_print-sukey && '",'.
  630. lh_body = lh_body && '"col01":"' && it_print-col01 && '",'.
  631. lh_body = lh_body && '"col02":"' && it_print-col02 && '",'.
  632. lh_body = lh_body && '"col03":"' && it_print-col03 && '",'.
  633. lh_body = lh_body && '"col04":"' && it_print-col04 && '",'.
  634. lh_body = lh_body && '"col05":"' && it_print-col05 && '",'.
  635. lh_body = lh_body && '"col06":"' && it_print-col06 && '",'.
  636. lh_body = lh_body && '"col07":"' && it_print-col07 && '",'.
  637. lh_body = lh_body && '"col08":"' && it_print-col08 && '",'.
  638. lh_body = lh_body && '"col09":"' && it_print-col09 && '",'.
  639. lh_body = lh_body && '"col10":"' && it_print-col10 && '"}'.
  640. ENDLOOP.
  641.  
  642. LOOP AT it_print WHERE colid = 'L'.
  643. lh_body = lh_body && ',{'.
  644. lh_body = lh_body && '"colid":"' && it_print-colid && '",'.
  645. lh_body = lh_body && '"cokey":"' && it_print-cokey && '",'.
  646. lh_body = lh_body && '"sukey":"' && it_print-sukey && '",'.
  647. lh_body = lh_body && '"col01":"' && it_print-col01 && '",'.
  648. lh_body = lh_body && '"col02":"' && it_print-col02 && '"}'.
  649. ENDLOOP.
  650.  
  651. LOOP AT it_print WHERE colid = 'S'.
  652. lh_body = lh_body && ',{'.
  653. lh_body = lh_body && '"colid":"' && it_print-colid && '",'.
  654. lh_body = lh_body && '"cokey":"' && it_print-cokey && '",'.
  655. lh_body = lh_body && '"sukey":"' && it_print-sukey && '",'.
  656. lh_body = lh_body && '"col01":"' && it_print-col01 && '",'.
  657. lh_body = lh_body && '"col02":"' && it_print-col02 && '",'.
  658. lh_body = lh_body && '"col03":"' && it_print-col03 && '",'.
  659. lh_body = lh_body && '"col04":"' && it_print-col04 && '",'.
  660. lh_body = lh_body && '"col05":"' && it_print-col05 && '",'.
  661. lh_body = lh_body && '"col06":"' && it_print-col06 && '",'.
  662. lh_body = lh_body && '"col07":"' && it_print-col07 && '",'.
  663. lh_body = lh_body && '"col08":"' && it_print-col08 && '"}'.
  664. ENDLOOP.
  665.  
  666. LOOP AT it_print WHERE colid = 'I'.
  667. lh_body = lh_body && ',{'.
  668. lh_body = lh_body && '"colid":"' && it_print-colid && '",'.
  669. lh_body = lh_body && '"cokey":"' && it_print-cokey && '",'.
  670. lh_body = lh_body && '"sukey":"' && it_print-sukey && '",'.
  671. lh_body = lh_body && '"col01":"' && it_print-col01 && '"}'.
  672. ENDLOOP.
  673.  
  674. lh_body = lh_body && ']'.
  675.  
  676. ENDFORM.
  677. *&---------------------------------------------------------------------*
  678. *& Form JOINDATA
  679. *&---------------------------------------------------------------------*
  680. * text
  681. *----------------------------------------------------------------------*
  682. * --> p1 text
  683. * <-- p2 text
  684. *----------------------------------------------------------------------*
  685. FORM joindata .
  686. LOOP AT it_hana INTO wa_msg.
  687. if wa_msg-msg cp '*Ship*cre*'.
  688. UPDATE ztship01
  689. SET col16 = wa_msg-shi
  690. WHERE cokey = p_var AND sukey = p_sukey.
  691. endif.
  692. APPEND wa_msg to it_msg.
  693. ENDLOOP.
  694. ENDFORM.
  695. *&---------------------------------------------------------------------*
  696. *& Form CONVERTING2
  697. *&---------------------------------------------------------------------*
  698. * text
  699. *----------------------------------------------------------------------*
  700. * --> p1 text
  701. * <-- p2 text
  702. *----------------------------------------------------------------------*
  703. FORM converting2 .
  704. clear : headerdata.
  705.  
  706. LOOP AT it_print WHERE colid = 'H'.
  707. headerdata-shipment_type = it_print-col01.
  708. headerdata-guid = it_print-sukey.
  709. SHIPMENTGUID = it_print-sukey.
  710. headerdata-trans_plan_pt = it_print-col02.
  711. headerdata-shipping_type = it_print-col03.
  712. * headerdata-shipment_route = it_print-col04.
  713. headerdata-container_id = it_print-col05.
  714. headerdata-external_id_1 = it_print-col06.
  715. headerdata-external_id_2 = it_print-col07.
  716. headerdata-description = it_print-col08.
  717. headerdata-status_plan = it_print-col09.
  718. headerdata-TENDERING_CARRIER_TRACK_ID = it_print-col11.
  719. headerdata-service_agent_id = it_print-col10.
  720. headerdata-SHIPPING_TYPE_PRE_LEG = it_print-col03.
  721. headerdata-text_4 = p_var.
  722. ENDLOOP.
  723.  
  724. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  725. EXPORTING
  726. input = headerdata-service_agent_id
  727. IMPORTING
  728. output = headerdata-service_agent_id.
  729.  
  730. LOOP AT it_print WHERE colid = 'L'.
  731. headerdeadline-time_type = it_print-col01.
  732. headerdeadline-time_stamp_utc = it_print-col02.
  733. headerdeadline-time_zone = it_print-col03.
  734. APPEND headerdeadline.
  735. ENDLOOP.
  736.  
  737. LOOP AT it_print WHERE colid = 'I'.
  738. itemdata-DELIVERY = it_print-col01.
  739. itemdata-ITENERARY = sy-tabix.
  740. append itemdata.
  741.  
  742. * itemonstage-STAGE_SEQ = '1'.
  743. * itemonstage-DELIVERY = it_print-col01.
  744. * append itemonstage.
  745. ENDLOOP.
  746.  
  747. data :
  748. fwdag TYPE bapishipmentstage-SERVICE_AGENT,
  749. it_prant TYPE TABLE OF ztship01 WITH HEADER LINE.
  750.  
  751. refresh : it_prant.
  752.  
  753. it_prant[] = it_print[].
  754.  
  755. LOOP AT it_print WHERE colid = 'S'.
  756. stagedata-stage_cat = it_print-col01.
  757. stagedata-stage_seq = it_print-col02.
  758. stagedata-shipping_type = it_print-col03.
  759. stagedata-leg_indicator = it_print-col04.
  760. stagedata-org_point = it_print-col05.
  761. stagedata-dest_point = it_print-col06.
  762. CLEAR : fwdag.
  763. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  764. EXPORTING
  765. input = it_print-col08
  766. IMPORTING
  767. output = fwdag.
  768. stagedata-service_agent = fwdag. "it_print-col08.
  769. stagedata-shpmnt_cost_rel = it_print-col07.
  770. APPEND stagedata.
  771.  
  772. LOOP AT it_prant WHERE colid = 'I'.
  773. itemonstage-STAGE_SEQ = it_print-col02.
  774. itemonstage-DELIVERY = it_prant-col01.
  775. append itemonstage.
  776. ENDLOOP.
  777.  
  778. ENDLOOP.
  779.  
  780. CALL FUNCTION 'BAPI_SHIPMENT_CREATE'
  781. EXPORTING
  782. headerdata = headerdata
  783. IMPORTING
  784. TRANSPORT = transport
  785. SHIPMENTGUID = SHIPMENTGUID
  786. TABLES
  787. headerdeadline = headerdeadline
  788. itemdata = itemdata
  789. stagedata = stagedata
  790. stagedeadline = stagedeadline
  791. itemonstage = itemonstage
  792. address = address
  793. hdunheader = hdunheader
  794. hdunitem = hdunitem
  795. return = return.
  796.  
  797. if sy-subrc = 0.
  798.  
  799. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  800. EXPORTING
  801. wait = 'X'.
  802. endif.
  803.  
  804. if transport is INITIAL.
  805. LOOP AT return.
  806. wa_msg-msg = return-message.
  807. APPEND wa_msg to it_msg.
  808. ENDLOOP.
  809.  
  810. else.
  811. wa_msg-msg = 'Shipment Created'.
  812. wa_msg-shi = transport.
  813. APPEND wa_msg to it_msg.
  814. UPDATE ztship01
  815. SET col16 = transport
  816. WHERE cokey = p_var AND sukey = p_sukey.
  817.  
  818. REFRESH bdc_data.
  819.  
  820. "======== bdc copy from zlhtest87
  821. perform bdc_dynpro using 'SAPMV56A' '1011'.
  822. perform bdc_field using 'BDC_CURSOR'
  823. 'VTTK-TKNUM'.
  824. perform bdc_field using 'BDC_OKCODE'
  825. '=MM_TKAL'.
  826. perform bdc_field using 'VTTK-TKNUM'
  827. transport.
  828. perform bdc_dynpro using 'SAPMV56A' '1020'.
  829. perform bdc_field using 'BDC_OKCODE'
  830. '=MM_ST01'.
  831. perform bdc_field using 'BDC_CURSOR'
  832. 'VTTK-TDLNR'.
  833. perform bdc_dynpro using 'SAPMV56A' '1020'.
  834. perform bdc_field using 'BDC_OKCODE'
  835. '=MM_SICH'.
  836. perform bdc_field using 'BDC_CURSOR'
  837. 'VTTK-VSART'.
  838. READ TABLE it_print WITH KEY colid = 'H'.
  839. perform bdc_field using 'VTTK-ROUTE'
  840. it_print-col04.
  841. perform bdc_field using 'VTTK-VSART'
  842. it_print-col03.
  843. "=======
  844.  
  845. CLEAR opt.
  846. opt-dismode = 'S'. "'A' --> via screen. "'S' --> langsung
  847. opt-updmode = 'S'.
  848. opt-defsize = 'X'.
  849. opt-racommit = 'X'.
  850. opt-nobinpt = 'X'.
  851. opt-nobiend = 'X'.
  852.  
  853. REFRESH bdc_message.
  854. CALL TRANSACTION 'VT02N'
  855. USING bdc_data
  856. MESSAGES INTO bdc_message
  857. OPTIONS FROM opt.
  858.  
  859. IF bdc_message[] IS NOT INITIAL.
  860.  
  861. DATA : str TYPE string.
  862. LOOP AT bdc_message INTO wa_message.
  863. CALL FUNCTION 'FORMAT_MESSAGE'
  864. EXPORTING
  865. id = wa_message-msgid
  866. lang = '-D'
  867. no = wa_message-msgnr
  868. v1 = wa_message-msgv1
  869. v2 = wa_message-msgv2
  870. v3 = wa_message-msgv3
  871. v4 = wa_message-msgv4
  872. IMPORTING
  873. msg = str
  874. EXCEPTIONS
  875. not_found = 1
  876. OTHERS = 2.
  877. IF sy-subrc <> 0.
  878. * Implement suitable error handling here
  879. ENDIF.
  880. wa_msg-msg = str.
  881. APPEND wa_msg to it_msg.
  882. ENDLOOP.
  883. ENDIF.
  884.  
  885. endif.
  886.  
  887.  
  888. ENDFORM.
  889.  
  890.  
  891. *&---------------------------------------------------------------------*
  892. *& Form bdc_dynpro
  893. *&---------------------------------------------------------------------*
  894. FORM bdc_dynpro USING program dynpro.
  895. CLEAR bdc_data.
  896. bdc_data-program = program.
  897. bdc_data-dynpro = dynpro.
  898. bdc_data-dynbegin = 'X'.
  899. APPEND bdc_data.
  900. ENDFORM. "BDC_DYNPRO
  901.  
  902. *----------------------------------------------------------------------*
  903. * Insert field *
  904. *----------------------------------------------------------------------*
  905. FORM bdc_field USING fnam fval.
  906. CLEAR bdc_data.
  907. bdc_data-fnam = fnam.
  908. bdc_data-fval = fval.
  909. APPEND bdc_data.
  910. ENDFORM. "BDC_FIELD
  911. *&---------------------------------------------------------------------*
  912. *& Form CHANGEROUTE
  913. *&---------------------------------------------------------------------*
  914. * text
  915. *----------------------------------------------------------------------*
  916. * --> p1 text
  917. * <-- p2 text
  918. *----------------------------------------------------------------------*
  919. FORM changeroute .
  920.  
  921. REFRESH bdc_data.
  922.  
  923. "-============
  924.  
  925. perform bdc_dynpro using 'ZSHIPROT' '1000'.
  926. perform bdc_field using 'BDC_CURSOR'
  927. 'CTU'.
  928. perform bdc_field using 'BDC_OKCODE'
  929. '=ONLI'.
  930. perform bdc_field using 'P_VAR'
  931. p_var.
  932. perform bdc_field using 'P_VAP'
  933. p_sukey.
  934. perform bdc_field using 'SESSION'
  935. ''.
  936. perform bdc_field using 'CTU'
  937. 'X'.
  938. perform bdc_field using 'CTUMODE'
  939. 'N'.
  940. perform bdc_field using 'USER'
  941. sy-uname.
  942. perform bdc_field using 'CUPDATE'
  943. 'L'.
  944. perform bdc_field using 'E_USER'
  945. sy-uname.
  946. perform bdc_field using 'NODATA'
  947. '/'.
  948. perform bdc_dynpro using 'SAPMSVMA' '0200'.
  949. perform bdc_field using 'BDC_OKCODE'
  950. '/EBACK'.
  951. perform bdc_field using 'BDC_CURSOR'
  952. 'VCLDIR-VCLNAME'.
  953. perform bdc_dynpro using 'SAPMSSY0' '0120'.
  954. perform bdc_field using 'BDC_OKCODE'
  955. '=BACK'.
  956. perform bdc_dynpro using 'ZSHIPROT' '1000'.
  957. perform bdc_field using 'BDC_OKCODE'
  958. '/EE'.
  959. *perform bdc_field using 'BDC_CURSOR'
  960. * p_var.
  961.  
  962. "============
  963.  
  964. CLEAR opt.
  965. opt-dismode = 'S'. "'A' --> via screen. "'S' --> langsung
  966. opt-updmode = 'S'.
  967. opt-defsize = 'X'.
  968. opt-racommit = 'X'.
  969. opt-nobinpt = 'X'.
  970. opt-nobiend = 'X'.
  971.  
  972. REFRESH bdc_message.
  973. CALL TRANSACTION 'ZSHIPROT'
  974. USING bdc_data
  975. MESSAGES INTO bdc_message
  976. OPTIONS FROM opt.
  977.  
  978. IF bdc_message[] IS NOT INITIAL.
  979.  
  980. DATA : str TYPE string.
  981. LOOP AT bdc_message INTO wa_message.
  982. CALL FUNCTION 'FORMAT_MESSAGE'
  983. EXPORTING
  984. id = wa_message-msgid
  985. lang = '-D'
  986. no = wa_message-msgnr
  987. v1 = wa_message-msgv1
  988. v2 = wa_message-msgv2
  989. v3 = wa_message-msgv3
  990. v4 = wa_message-msgv4
  991. IMPORTING
  992. msg = str
  993. EXCEPTIONS
  994. not_found = 1
  995. OTHERS = 2.
  996. IF sy-subrc <> 0.
  997. * Implement suitable error handling here
  998. ENDIF.
  999. * wa_msg-msg = str.
  1000. * APPEND wa_msg to it_msg.
  1001. ENDLOOP.
  1002. ENDIF.
  1003.  
  1004.  
  1005. ENDFORM.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement