GOS Mass Downloader

Nützliche Abap Codes und Code Fragmente

GOS Mass Downloader

Postby Tron » Thu Feb 06, 2020 4:45 pm

000.png
000.png (52.22 KiB) Viewed 697 times

002.png
002.png (123.98 KiB) Viewed 696 times

003.png
003.png (87.05 KiB) Viewed 696 times

Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. *&---------------------------------------------------------------------*
  2. *& Report  Z_GOS_MASS_DOWNLOAD
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *&
  6. *&
  7. *&---------------------------------------------------------------------*
  8. REPORT z_ar_sgos_download.
  9.  
  10. *TABLES: sscrfields.
  11. TYPE-POOLS: icon,slis.
  12. * Tabellen der Varianten
  13. * ltdx
  14. * Ltdxd
  15. * Ltdxs
  16.  
  17. CONSTANTS ht(1) VALUE %_horizontal_tab.
  18.  
  19. DATA filter TYPE lvc_t_filt WITH HEADER LINE.
  20. * Grid Parameter
  21. DATA: ok_code            LIKE sy-ucomm,
  22.       g_container        TYPE scrfname VALUE 'GRID1',
  23.       grid1              TYPE REF TO cl_gui_alv_grid,
  24.       g_custom_container TYPE REF TO cl_gui_custom_container,
  25.       is_variant         TYPE disvariant.
  26.  
  27. *--- Field catalog table
  28. DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
  29. *--- Layout structure
  30. DATA gs_layout TYPE lvc_s_layo .
  31.  
  32. * LT_EXCLUDE => Tabelle zum Ausschliessen von Funktionen innerhalb
  33. * der Toolbar des ALV-Grid
  34. DATA: lt_exclude TYPE ui_functions,
  35.       ls_exclude TYPE ui_func.
  36.  
  37. * ALV Datenquelle DATA cellcolors TYPE lvc_t_scol .
  38. DATA it_data TYPE TABLE OF zar_gos_atta_alv.
  39. FIELD-SYMBOLS <p> TYPE zar_gos_atta_alv.
  40.  
  41. * für autom. Variante DEFAULT laden
  42.   l_report   TYPE raldb_repo,
  43.   l_variante TYPE raldb_vari,
  44.   BEGIN OF t_info OCCURS 0,
  45.     typ(1),
  46.     null(1),
  47.     line(120),
  48.   END OF t_info.
  49.  
  50. TYPES: BEGIN OF ty_toaxx,
  51.          sap_object TYPE saeanwdid,
  52.          object_id  TYPE saeobjid,
  53.          archiv_id  TYPE saearchivi,
  54.          arc_doc_id TYPE saeardoid,
  55.          ar_object  TYPE saeobjart,
  56.        END OF ty_toaxx.
  57. DATA it_toa TYPE TABLE OF ty_toaxx.
  58.  
  59.  
  60. * 4 select options
  61. DATA ty_srgbtbrel TYPE srgbtbrel.
  62. DATA ty_sap_object TYPE toaom-sap_object.
  63. DATA ty_doctype TYPE toaom-ar_object.
  64. DATA ty_docid TYPE toa01-object_id.
  65.  
  66. "ranges r_altab for ty_linktab.
  67. DATA t_ltab TYPE TABLE OF toaom.
  68. DATA s_ltab TYPE toaom.
  69.  
  70.  
  71.   SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-002.
  72.   SELECT-OPTIONS s_doc FOR ty_srgbtbrel-instid_a OBLIGATORY.
  73.   SELECT-OPTIONS s_bus FOR ty_sap_object OBLIGATORY.
  74.   PARAMETERS p_type TYPE srgbtbrel-reltype OBLIGATORY DEFAULT 'ATTA' MODIF ID m1.
  75.   PARAMETERS c_kpro AS CHECKBOX.
  76.   SELECTION-SCREEN END OF BLOCK a.
  77.  
  78.  
  79.  
  80.   SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-003.
  81.   SELECT-OPTIONS s_id FOR ty_docid OBLIGATORY.
  82.   SELECT-OPTIONS s_obj FOR ty_sap_object OBLIGATORY.
  83.   SELECT-OPTIONS s_doctyp FOR  ty_doctype.
  84.   PARAMETERS c_alink AS CHECKBOX.
  85.   SELECTION-SCREEN END OF BLOCK b.
  86.  
  87.  
  88.   SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-004.
  89.   PARAMETERS p_path(40) TYPE c LOWER CASE DEFAULT 'c:\temp'.
  90.   PARAMETERS p_maxhit(10) TYPE n DEFAULT '10000'.
  91.   SELECTION-SCREEN END OF BLOCK c.
  92.  
  93.  
  94.  
  95.   REFRESH it_data.
  96.  
  97.  
  98.   IF NOT c_kpro IS INITIAL.
  99.  
  100.     IF p_maxhit IS INITIAL.
  101.       SELECT * FROM srgbtbrel INTO CORRESPONDING FIELDS OF TABLE it_data
  102.         WHERE
  103.         reltype = p_type AND
  104.         typeid_a IN s_bus AND
  105.       instid_a IN s_doc ORDER BY PRIMARY KEY.
  106.     ELSE.
  107.       SELECT * FROM srgbtbrel UP TO p_maxhit ROWS INTO CORRESPONDING FIELDS OF TABLE it_data
  108.         WHERE
  109.         reltype = p_type AND
  110.         typeid_a IN s_bus AND
  111.       instid_a IN s_doc ORDER BY PRIMARY KEY.
  112.     ENDIF.
  113.  
  114.     LOOP AT it_data ASSIGNING <p>.
  115.       PERFORM get_phio_id .
  116.       IF NOT <p>-phio_id IS INITIAL.
  117.         SELECT SINGLE * FROM soffphf INTO CORRESPONDING FIELDS OF <p> WHERE
  118.         phio_id = <p>-phio_id.
  119.       ENDIF.
  120.       IF NOT <p>-typeid_a IS INITIAL.
  121.         SELECT SINGLE stext FROM tojtt INTO <p>-stext WHERE
  122.           name = <p>-typeid_a AND
  123.         language = sy-langu.
  124.       ENDIF.
  125.     ENDLOOP.
  126.  
  127.   ENDIF." NOT c_kpro IS INITIAL.
  128.  
  129.   IF NOT c_alink IS INITIAL.
  130.  
  131. * get all Link tables TOAxx
  132.     SELECT * FROM toaom INTO TABLE t_ltab
  133.      WHERE
  134.      sap_object IN s_obj AND
  135.      ar_object IN s_doctyp AND
  136.      ar_status NE ' '
  137.       ORDER BY PRIMARY KEY.
  138.  
  139.     SORT t_ltab ASCENDING BY connection.
  140.     DELETE ADJACENT DUPLICATES FROM t_ltab COMPARING connection.
  141.  
  142.  
  143.     IF p_maxhit IS INITIAL.
  144.       REFRESH it_toa.
  145.       LOOP AT t_ltab INTO s_ltab.
  146.  
  147.         SELECT sap_object object_id  archiv_id  arc_doc_id ar_object
  148.         FROM (s_ltab-connection)
  149.         APPENDING TABLE it_toa  WHERE
  150.          sap_object IN s_obj AND
  151.          object_id IN s_id AND
  152.          ar_object IN s_doctyp
  153.          ORDER BY PRIMARY KEY.
  154.  
  155.       ENDLOOP.
  156.  
  157.     ELSE.
  158.  
  159.       REFRESH it_toa.
  160.       LOOP AT t_ltab INTO s_ltab.
  161.  
  162.         SELECT sap_object object_id  archiv_id  arc_doc_id ar_object
  163.         FROM (s_ltab-connection)
  164.         UP TO p_maxhit ROWS
  165.         APPENDING TABLE it_toa  WHERE
  166.          sap_object IN s_obj AND
  167.          object_id IN s_id AND
  168.          ar_object IN s_doctyp
  169.          ORDER BY PRIMARY KEY.
  170.  
  171.       ENDLOOP.
  172.  
  173.     ENDIF. "p_maxhit
  174.  
  175.     PERFORM get_alinks.
  176.  
  177.   ENDIF."c_alink IS INITIAL
  178.  
  179.  
  180.   CALL SCREEN 100.
  181.  
  182.   EXIT.
  183.  
  184.  
  185. ** Lade Variante sy-uname
  186.   l_report   = sy-repid.
  187.   l_variante = sy-uname.
  188.  
  189.  
  190.   CALL FUNCTION 'RS_COVERPAGE_SELECTIONS'
  191.     EXPORTING
  192.       report  = l_report
  193.       variant = l_variante
  194.     TABLES
  195.       infotab = t_info
  196.     EXCEPTIONS
  197.       OTHERS  = 3.
  198.  
  199.  
  200. AT SELECTION-SCREEN OUTPUT.
  201.   LOOP AT SCREEN.
  202.  
  203.     IF screen-group1 = 'M1'.
  204.       screen-input = 0.
  205.       MODIFY SCREEN. " Disable for input
  206.     ENDIF.
  207.  
  208.  
  209.  
  210. *---------------------------------------------------------------------*
  211. *       CLASS lcl_event_handler DEFINITION
  212. *---------------------------------------------------------------------*
  213. *
  214. *---------------------------------------------------------------------*
  215. CLASS lcl_event_handler DEFINITION .
  216.   PUBLIC SECTION .
  217.     METHODS:
  218. *--To add new functional buttons to the ALV toolbar
  219.       handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
  220.         IMPORTING e_object e_interactive ,
  221.  
  222. *--To implement user commands
  223.       handle_user_command
  224.                     FOR EVENT user_command OF cl_gui_alv_grid
  225.         IMPORTING e_ucomm.
  226.  
  227.  
  228.   PRIVATE SECTION.
  229. ENDCLASS.                    "lcl_event_handler DEFINITION
  230.  
  231.  
  232.  
  233. *---------------------------------------------------------------------*
  234. *       CLASS lcl_event_handler IMPLEMENTATION
  235. *---------------------------------------------------------------------*
  236. *
  237. *---------------------------------------------------------------------*
  238. CLASS lcl_event_handler IMPLEMENTATION .
  239.  
  240. *--Handle Toolbar
  241.   METHOD handle_toolbar.
  242.     PERFORM handle_toolbar USING e_object e_interactive .
  243.   ENDMETHOD .                    "handle_toolbar
  244.  
  245. *--Handle User Command
  246.   METHOD handle_user_command .
  247.     PERFORM handle_user_command USING e_ucomm .
  248.   ENDMETHOD.                    "handle_user_command
  249.  
  250. *--Handle user toolbar menu
  251. *  METHOD handle_menu_button .
  252. *    PERFORM handle_menu_button USING e_object e_ucomm .
  253. *  ENDMETHOD .                    "handle_menu_button
  254.  
  255. ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
  256.  
  257. DATA gr_event_handler TYPE REF TO lcl_event_handler .
  258.  
  259.  
  260.  
  261. *---------------------------------------------------------------------*
  262. *       MODULE PBO OUTPUT                                             *
  263. *---------------------------------------------------------------------*
  264. MODULE pbo OUTPUT.
  265.  
  266.   IF g_custom_container IS INITIAL.
  267.     CREATE OBJECT g_custom_container
  268.       EXPORTING
  269.         container_name = g_container.
  270.     CREATE OBJECT grid1
  271.       EXPORTING
  272.         i_parent = g_custom_container.
  273.  
  274. *--Creating an instance for the event handler
  275.     CREATE OBJECT gr_event_handler .
  276.  
  277. *----Preparing field catalog.
  278.     PERFORM prepare_field_catalog TABLES gt_fieldcat[] .
  279. *----Preparing layout structure
  280.     PERFORM prepare_layout CHANGING gs_layout .
  281. *----Preparing Disable Toolbar Buttons
  282.     PERFORM change_buttons .
  283.  
  284.     is_variant-report = sy-repid.
  285.     is_variant-variant = '/GLOB_DEF'.
  286.  
  287.     CALL METHOD grid1->set_table_for_first_display
  288.       EXPORTING
  289.         is_variant           = is_variant
  290.         i_save               = 'A'
  291.         is_layout            = gs_layout
  292.         it_toolbar_excluding = lt_exclude
  293.       CHANGING
  294.         it_outtab            = it_data[]
  295.         it_fieldcatalog      = gt_fieldcat[].
  296.  
  297.  
  298. *--Registering handler methods to handle ALV Grid events JG
  299.  
  300.     SET HANDLER gr_event_handler->handle_toolbar FOR grid1.
  301.     SET HANDLER gr_event_handler->handle_user_command FOR grid1.
  302.  
  303. * Switch Toolbar of Grid to interactive
  304.  
  305.     CALL METHOD grid1->set_toolbar_interactive.
  306.  
  307. * Der GRID1 wird noch refreshed
  308.     CALL METHOD grid1->refresh_table_display.
  309.  
  310.   ENDIF.
  311.  
  312.   SET PF-STATUS 'MAIN100'.
  313.   SET TITLEBAR 'AUSW' WITH text-001.
  314. ENDMODULE.                    "PBO OUTPUT
  315. *---------------------------------------------------------------------*
  316. *       MODULE PAI INPUT                                              *
  317. *---------------------------------------------------------------------*
  318. MODULE pai INPUT.
  319. *   to react on oi_custom_events:
  320.   CALL METHOD cl_gui_cfw=>dispatch.
  321.   CASE ok_code.
  322.     WHEN 'EXIT'.
  323.       PERFORM exit_program.
  324.     WHEN OTHERS.
  325. *     do nothing
  326.   CLEAR ok_code.
  327. ENDMODULE.                    "PAI INPUT
  328. *---------------------------------------------------------------------*
  329. *       FORM EXIT_PROGRAM                                             *
  330. *---------------------------------------------------------------------*
  331. FORM exit_program.
  332. *  CALL METHOD G_CUSTOM_CONTAINER->FREE.
  333. *  CALL METHOD CL_GUI_CFW=>FLUSH.
  334.   LEAVE TO SCREEN 0.
  335. ENDFORM.                    "EXIT_PROGRAM
  336. *&--------------------------------------------------------------------*
  337. *&      Form  Change_buttons
  338. *&--------------------------------------------------------------------*
  339. *       text
  340. *---------------------------------------------------------------------*
  341. FORM change_buttons .
  342. * Kein Symbol für Drucken / Graphik / Info
  343.   ls_exclude = cl_gui_alv_grid=>mc_fc_print_back.
  344.   APPEND ls_exclude TO lt_exclude.
  345.   ls_exclude = cl_gui_alv_grid=>mc_fc_graph.
  346.   APPEND ls_exclude TO lt_exclude.
  347.   ls_exclude = cl_gui_alv_grid=>mc_fc_info.
  348.   APPEND ls_exclude TO lt_exclude.
  349.  
  350. ENDFORM.                    "Change_buttons
  351. *&--------------------------------------------------------------------*
  352. *&      Form  prepare_layout
  353. *&--------------------------------------------------------------------*
  354. *       text
  355. *---------------------------------------------------------------------*
  356. *      -->PS_LAYOUT  text
  357. *---------------------------------------------------------------------*
  358. FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
  359.   DATA rfctxt TYPE rfcdoc-rfcdoc1.
  360.  
  361.   ps_layout-zebra = 'X' .
  362. *ps_layout-cwidth_opt ='X'.
  363.   ps_layout-numc_total = ' '.
  364.   ps_layout-no_merging = 'X'.
  365.   ps_layout-no_rowmark = ' '.
  366.   ps_layout-sel_mode = 'A'.
  367.  
  368. ENDFORM.                    "prepare_layout
  369. *&--------------------------------------------------------------------*
  370. *&      Form  handle_toolbar
  371. *&--------------------------------------------------------------------*
  372. *       text
  373. *---------------------------------------------------------------------*
  374. *      -->I_OBJECT   text
  375. *---------------------------------------------------------------------*
  376. FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set
  377. e_interactive .
  378.  
  379.   DATA: ls_toolbar TYPE stb_button.
  380.  
  381. * Paltzhalter / Seperator
  382.   CLEAR ls_toolbar.
  383.   MOVE 3 TO ls_toolbar-butn_type.
  384.   APPEND ls_toolbar TO i_object->mt_toolbar.
  385.  
  386.  
  387. * Button MARKIEREN
  388.   CLEAR ls_toolbar.
  389.   MOVE 'MARK' TO ls_toolbar-function.                       "#EC NOTEXT
  390.   MOVE icon_checkbox TO ls_toolbar-icon.
  391.   MOVE 'TOGGLE Select'(201) TO ls_toolbar-quickinfo.
  392.   MOVE ' TOGGLE Select'(201) TO ls_toolbar-text.
  393.   MOVE ' ' TO ls_toolbar-disabled.                          "#EC NOTEXT
  394.   APPEND ls_toolbar TO i_object->mt_toolbar.
  395.  
  396. * Button MARK all Filtered
  397.   CLEAR ls_toolbar.
  398.   MOVE 'MARK_ALL_FILTERED' TO ls_toolbar-function.          "#EC NOTEXT
  399.   MOVE  icon_filter TO ls_toolbar-icon.
  400.   MOVE 'MARK ALL FILTERED'(201) TO ls_toolbar-quickinfo.
  401.   MOVE ' MARK ALL FILTERED'(201) TO ls_toolbar-text.
  402.   MOVE ' ' TO ls_toolbar-disabled.                          "#EC NOTEXT
  403.   APPEND ls_toolbar TO i_object->mt_toolbar.
  404.  
  405. *  Button Select ALL
  406.   CLEAR ls_toolbar.
  407.   MOVE 'SELECTALL' TO ls_toolbar-function.                  "#EC NOTEXT
  408.   MOVE icon_select_all TO ls_toolbar-icon.
  409.   MOVE 'Select ALL'(202) TO ls_toolbar-quickinfo.
  410.   MOVE ' Select ALL'(202) TO ls_toolbar-text.
  411.   MOVE ' ' TO ls_toolbar-disabled.                          "#EC NOTEXT
  412.   APPEND ls_toolbar TO i_object->mt_toolbar.
  413.  
  414. * Button Deselect ALL
  415.   CLEAR ls_toolbar.
  416.   MOVE 'CLEAR' TO ls_toolbar-function.                      "#EC NOTEXT
  417.   MOVE icon_deselect_all TO ls_toolbar-icon.
  418.   MOVE 'RESET Select ALL'(202) TO ls_toolbar-quickinfo.
  419.   MOVE ' RESET Select ALL'(202) TO ls_toolbar-text.
  420.   MOVE ' ' TO ls_toolbar-disabled.                          "#EC NOTEXT
  421.   APPEND ls_toolbar TO i_object->mt_toolbar.
  422.  
  423. * Paltzhalter / Seperator
  424.   CLEAR ls_toolbar.
  425.   MOVE 3 TO ls_toolbar-butn_type.
  426.   APPEND ls_toolbar TO i_object->mt_toolbar.
  427.  
  428. * Download selected
  429.   CLEAR ls_toolbar.
  430.   MOVE 'DOWNLOAD' TO ls_toolbar-function.                   "#EC NOTEXT
  431.   MOVE icon_system_save TO ls_toolbar-icon.
  432.   MOVE 'Download Documents'(203) TO ls_toolbar-quickinfo.
  433.   MOVE ' Download Documents'(203) TO ls_toolbar-text.
  434.   MOVE ' ' TO ls_toolbar-disabled.                          "#EC NOTEXT
  435.   APPEND ls_toolbar TO i_object->mt_toolbar.
  436.  
  437. ENDFORM .                    "handle_toolbar
  438.  
  439.  
  440. *&---------------------------------------------------------------------*
  441. *&      Form  handle_user_command
  442. *&---------------------------------------------------------------------*
  443. *       text
  444. *----------------------------------------------------------------------*
  445.  
  446. FORM handle_user_command USING i_ucomm TYPE syucomm .
  447.   DATA lt_selected_rows TYPE lvc_t_roid .
  448.   DATA ls_selected_row TYPE lvc_s_roid .
  449.   DATA lv_name TYPE epsfili-name.
  450.   DATA lv_flag(1).
  451.   DATA lv_stable TYPE lvc_s_stbl.
  452.   DATA i TYPE i.
  453.   DATA lv_tit(80).
  454.   DATA lfiltered TYPE lvc_t_fidx.
  455.  
  456.   CASE i_ucomm .
  457.     WHEN 'MARK' .
  458.  
  459.       CALL METHOD grid1->get_selected_rows
  460.         IMPORTING
  461.           et_row_no = lt_selected_rows.
  462. *     War was selektiert ?
  463.       READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
  464.  
  465.       IF sy-subrc NE 0 .
  466.         MESSAGE s000(su) WITH 'Select a row!'(205).
  467.       ELSE.
  468.         LOOP AT lt_selected_rows INTO ls_selected_row.
  469.           IF ls_selected_row-row_id NE 0.
  470.  
  471.             READ TABLE it_data ASSIGNING <p> INDEX ls_selected_row-row_id.
  472.             IF <p>-xfeld = 'X'.
  473.               <p>-xfeld = space.
  474.             ELSE.
  475.               <p>-xfeld = 'X'.
  476.             ENDIF.
  477.             lv_flag = <p>-xfeld.
  478.  
  479.           ENDIF.
  480.         ENDLOOP.
  481.  
  482.       ENDIF .
  483.  
  484.     WHEN 'MARK_ALL_FILTERED'.
  485.  
  486.       CALL METHOD grid1->get_filtered_entries
  487.         IMPORTING
  488.           et_filtered_entries = lfiltered.
  489.  
  490.       LOOP AT it_data ASSIGNING <p>.
  491.         READ TABLE lfiltered WITH KEY = sy-tabix TRANSPORTING NO FIELDS.
  492.         IF sy-subrc NE 0.
  493.           <p>-xfeld = 'X'.
  494.         ENDIF.
  495.       ENDLOOP.
  496.  
  497. * Delete all marks
  498.     WHEN 'CLEAR' .
  499.       LOOP AT it_data ASSIGNING <p>.
  500.         <p>-xfeld = space.
  501.       ENDLOOP.
  502.  
  503. * marks all
  504.     WHEN 'SELECTALL' .
  505.       LOOP AT it_data ASSIGNING <p>.
  506.         <p>-xfeld = 'X'.
  507.       ENDLOOP.
  508.  
  509. * download selected
  510.     WHEN 'DOWNLOAD'.
  511.  
  512.       LOOP AT it_data ASSIGNING <p>.
  513.         CLEAR <p>-sicon.
  514.       ENDLOOP.
  515.  
  516.       LOOP AT it_data ASSIGNING <p> WHERE NOT xfeld IS INITIAL AND NOT file_name IS INITIAL.
  517.         IF <p>-reltype = 'ATTA'.
  518.           PERFORM getdoc.
  519.         ELSE.
  520.           PERFORM getdoc_alink.
  521.         ENDIF.
  522.         <p>-sicon = '@01@'.
  523.       ENDLOOP.
  524.  
  525.  
  526.   ENDCASE .
  527.  
  528.  
  529.   CLEAR i.
  530.   LOOP AT it_data ASSIGNING <p> WHERE NOT xfeld IS INITIAL.
  531.     i = i + 1.
  532.  
  533.   WRITE i TO lv_tit.
  534.   CONDENSE lv_tit NO-GAPS.
  535.   CONCATENATE text-001 '/' lv_tit 'selected' INTO lv_tit SEPARATED BY space.
  536.   SET TITLEBAR 'AUSW' WITH lv_tit.
  537.  
  538.  
  539.  
  540.   lv_stable-row = 'X'.
  541.   CALL METHOD grid1->refresh_table_display
  542.     EXPORTING
  543.       is_stable = lv_stable
  544.     EXCEPTIONS
  545.       finished  = 1
  546.       OTHERS    = 2.
  547.  
  548. ENDFORM.                    "handle_user_command
  549.  
  550. *&--------------------------------------------------------------------*
  551. *&      Form  prepare_field_catalog
  552. *&--------------------------------------------------------------------*
  553. *       text
  554. *---------------------------------------------------------------------*
  555. *      -->PT_FIELDCATtext
  556. *---------------------------------------------------------------------*
  557. FORM prepare_field_catalog TABLES pt_fieldcat TYPE lvc_t_fcat .
  558.  
  559.   DATA ls_fcat TYPE lvc_s_fcat .
  560.  
  561.   FIELD-SYMBOLS <f> TYPE  lvc_s_fcat .
  562.  
  563. *  DATA lv_depth TYPE i.
  564.  
  565.   CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  566.     EXPORTING
  567.       i_structure_name       = 'ZAR_GOS_ATTA_ALV'
  568.     CHANGING
  569.       ct_fieldcat            = pt_fieldcat[]
  570.     EXCEPTIONS
  571.       inconsistent_interface = 1
  572.       program_error          = 2
  573.       OTHERS                 = 3.
  574.  
  575.   IF sy-subrc <> 0.
  576. *--Exception handling
  577.   ENDIF.
  578.  
  579.   READ TABLE pt_fieldcat ASSIGNING <f> WITH KEY fieldname =  'XFELD'.
  580.   IF sy-subrc = 0.
  581.     <f>-coltext = 'Select'.
  582.     <f>-reptext = 'Select'.
  583.     <f>-checkbox = 'X'.
  584.     <f>-scrtext_l = 'Select'.
  585.     <f>-scrtext_m = 'Sel'.
  586.     <f>-scrtext_s = 'x'.
  587.     <f>-ref_table  = 'KAEP_COAC'.
  588.     <f>-tabname = '1'.
  589.   ENDIF.
  590.  
  591.  
  592.   READ TABLE pt_fieldcat ASSIGNING <f> WITH KEY fieldname = 'SICON'.
  593.   IF sy-subrc = 0.
  594.     <f>-icon = 'X'.
  595.     <f>-coltext = 'Status'.
  596.     <f>-reptext = 'Status'.
  597.     <f>-scrtext_l = 'Status'.
  598.     <f>-scrtext_m = 'Status'.
  599.     <f>-scrtext_s = 'Status'.
  600.   ENDIF.
  601.  
  602.  
  603. ENDFORM .                    "prepare_field_catalog
  604. FORM get_phio_id .
  605.   DATA l_object_id TYPE soodk.
  606.   DATA t_objcont TYPE TABLE OF soli.
  607.   DATA s_objcont TYPE soli.
  608.   DATA l_loio TYPE sdok_loid.
  609.  
  610.  
  611.   l_object_id = <p>-instid_b+17.
  612.  
  613.   CALL FUNCTION 'SO_OBJECT_GET_CONTENT'
  614.     EXPORTING
  615.       object_id        = l_object_id
  616.     TABLES
  617.       objcont          = t_objcont
  618.     EXCEPTIONS
  619.       archive_error    = 1
  620.       object_not_exist = 2
  621.       OTHERS           = 3.
  622.  
  623.   IF sy-subrc <> 0.
  624.   ENDIF.
  625.  
  626.   READ TABLE t_objcont INTO s_objcont INDEX 1.
  627.  
  628.   IF sy-subrc <> 0.
  629. *    MESSAGE s000(su) WITH 'No document for' <p>-instid_a 'found!' DISPLAY LIKE 'E'.
  630.     CLEAR <p>-phio_id.
  631.     CLEAR <p>-stor_cat.
  632.   ELSE.
  633.  
  634.     IF s_objcont-line CS '=SOFFLOIO'.
  635.       SPLIT s_objcont-line AT '  ' INTO l_loio l_loio.
  636.  
  637.       SELECT SINGLE phio_id stor_cat FROM soffphio INTO
  638.       (<p>-phio_id, <p>-stor_cat)
  639.       WHERE loio_id = l_loio.
  640.  
  641.     ENDIF.
  642.  
  643.   ENDIF.
  644.  
  645.  
  646.  
  647. FORM getdoc.
  648.  
  649.  
  650.   DATA l_path TYPE char255.
  651.   DATA l_dir TYPE string.
  652.   DATA l_rc TYPE i.
  653.   DATA ls_comps TYPE scms_stinf.
  654.   DATA lt_comps TYPE TABLE OF scms_stinf.
  655.  
  656.   PERFORM checkpath.
  657.  
  658.   CONCATENATE p_path '\' <p>-phio_id '\' <p>-file_name INTO l_path.
  659.  
  660.   CALL FUNCTION 'SCMS_DOC_INFO'
  661.     EXPORTING
  662. *     MANDT                 = SY-MANDT
  663.       stor_cat              = <p>-stor_cat
  664. *     CREP_ID               = ' '
  665.       doc_id                = <p>-phio_id
  666. *     PHIO_ID               =
  667. *     SIGNATURE             = 'X'
  668. *     SECURITY              = ' '
  669. *     NO_HTTP_LOG           = ' '
  670. * IMPORTING
  671. *     CREA_TIME             =
  672. *     CREA_DATE             =
  673. *     CHNG_TIME             =
  674. *     CHNG_DATE             =
  675. *     STATUS                =
  676.     TABLES
  677.       comps                 = lt_comps
  678.     EXCEPTIONS
  679.       bad_storage_type      = 1
  680.       bad_request           = 2
  681.       unauthorized          = 3
  682.       not_found             = 4
  683.       conflict              = 5
  684.       internal_server_error = 6
  685.       error_http            = 7
  686.       error_signature       = 8
  687.       error_config          = 9
  688.       error_hierarchy       = 10
  689.       error_parameter       = 11
  690.       error                 = 12
  691.       OTHERS                = 13.
  692.  
  693.   IF sy-subrc <> 0.
  694. *    logg ls-phio_id sy-subrc 'Info'.
  695.   ENDIF.
  696.  
  697.   LOOP AT lt_comps INTO ls_comps.
  698.     IF NOT ls_comps-comp_id IS INITIAL.
  699.       <p>-file_name = ls_comps-comp_id.
  700.     ENDIF.
  701.     EXIT.
  702.  
  703.  
  704.   CALL FUNCTION 'SCMS_DOC_READ_FILE'
  705.     EXPORTING
  706. *     MANDT                 = SY-MANDT
  707.       stor_cat              = <p>-stor_cat
  708. *     CREP_ID               = ' '
  709.       doc_id                = <p>-phio_id
  710. *     PHIO_ID               =
  711.       comp_id               = <p>-file_name
  712.       path                  = l_path
  713. *     FRONTEND              = 'X'
  714. *     SIGNATURE             = 'X'
  715.       security              = ' '
  716. *     NO_CACHE              = ' '
  717. *     P_TRANSFER_PHIO       =
  718. * IMPORTING
  719. *     SIZE                  =
  720. *     MIMETYPE              =
  721.     EXCEPTIONS
  722.       bad_storage_type      = 1
  723.       bad_request           = 2
  724.       unauthorized          = 3
  725.       not_found             = 4
  726.       conflict              = 5
  727.       internal_server_error = 6
  728.       error_http            = 7
  729.       error_signature       = 8
  730.       error_config          = 9
  731.       error_hierarchy       = 10
  732.       error_format          = 11
  733.       error_open            = 12
  734.       error_download        = 13
  735.       error_parameter       = 14
  736.       error                 = 15
  737.       OTHERS                = 16.
  738.  
  739.   IF sy-subrc <> 0.
  740. *    logg ls-phio_id sy-subrc 'Download 1'.
  741.  
  742.     CLEAR <p>-file_name .
  743.     CALL FUNCTION 'SCMS_DOC_READ_FILE'
  744.       EXPORTING
  745. *       MANDT                 = SY-MANDT
  746.         stor_cat              = <p>-stor_cat
  747. *       CREP_ID               = ' '
  748.         doc_id                = <p>-phio_id
  749. *       PHIO_ID               =
  750.         comp_id               = <p>-file_name
  751.         path                  = l_path
  752. *       FRONTEND              = 'X'
  753. *       SIGNATURE             = 'X'
  754.         security              = ' '
  755. *       NO_CACHE              = ' '
  756. *       P_TRANSFER_PHIO       =
  757. * IMPORTING
  758. *       SIZE                  =
  759. *       MIMETYPE              =
  760.       EXCEPTIONS
  761.         bad_storage_type      = 1
  762.         bad_request           = 2
  763.         unauthorized          = 3
  764.         not_found             = 4
  765.         conflict              = 5
  766.         internal_server_error = 6
  767.         error_http            = 7
  768.         error_signature       = 8
  769.         error_config          = 9
  770.         error_hierarchy       = 10
  771.         error_format          = 11
  772.         error_open            = 12
  773.         error_download        = 13
  774.         error_parameter       = 14
  775.         error                 = 15
  776.         OTHERS                = 16.
  777.     IF sy-subrc <> 0.
  778. *      logg ls-phio_id sy-subrc 'Download 2'.
  779.       EXIT.
  780.     ENDIF.
  781.  
  782.   ENDIF.
  783.  
  784.  
  785. ENDFORM.                    "Getdoc
  786.  
  787. FORM checkpath.
  788.   DATA l_dir TYPE string.
  789.   DATA l_rc1 TYPE abap_bool.
  790.   DATA l_rc TYPE i.
  791.  
  792. *    CONCATENATE p_path g_dadd  INTO l_dir.
  793.   l_dir = p_path.
  794.   CALL METHOD cl_gui_frontend_services=>directory_exist
  795.     EXPORTING
  796.       directory = l_dir
  797.     RECEIVING
  798.       result    = l_rc1.
  799.  
  800.   IF sy-subrc <> 0.
  801.   ENDIF.
  802.  
  803.   IF l_rc1 = abap_false.
  804. * create Subfolder
  805.     CALL METHOD cl_gui_frontend_services=>directory_create
  806.       EXPORTING
  807.         directory                = l_dir
  808.       CHANGING
  809.         rc                       = l_rc
  810.       EXCEPTIONS
  811.         directory_create_failed  = 1
  812.         cntl_error               = 2
  813.         error_no_gui             = 3
  814.         directory_access_denied  = 4
  815.         directory_already_exists = 5
  816.         path_not_found           = 6
  817.         unknown_error            = 7
  818.         not_supported_by_gui     = 8
  819.         wrong_parameter          = 9
  820.         OTHERS                   = 10.
  821.  
  822.   ENDIF.
  823.  
  824.   CONCATENATE p_path '\'  <p>-phio_id INTO l_dir.
  825.  
  826.   CALL METHOD cl_gui_frontend_services=>directory_exist
  827.     EXPORTING
  828.       directory = l_dir
  829.     RECEIVING
  830.       result    = l_rc1.
  831.  
  832.   IF sy-subrc <> 0.
  833.   ENDIF.
  834.  
  835.   IF l_rc1 = abap_false.
  836. * create Subfolder
  837.     CALL METHOD cl_gui_frontend_services=>directory_create
  838.       EXPORTING
  839.         directory                = l_dir
  840.       CHANGING
  841.         rc                       = l_rc
  842.       EXCEPTIONS
  843.         directory_create_failed  = 1
  844.         cntl_error               = 2
  845.         error_no_gui             = 3
  846.         directory_access_denied  = 4
  847.         directory_already_exists = 5
  848.         path_not_found           = 6
  849.         unknown_error            = 7
  850.         not_supported_by_gui     = 8
  851.         wrong_parameter          = 9
  852.         OTHERS                   = 10.
  853.  
  854.     l_rc = sy-subrc.
  855.     IF l_rc <> 0.
  856.       IF l_rc NE 5.
  857. *        logg ls-phio_id l_rc 'Directory err'.
  858.         EXIT.
  859.       ENDIF.
  860. *      logg ls-phio_id '5' 'Directory exist'.
  861.     ENDIF.
  862.  
  863.   ENDIF.
  864.  
  865. ENDFORM.                    "CheckPath
  866.  
  867. FORM get_alinks.
  868.  
  869.   DATA:
  870.     s_alv           TYPE zar_gos_atta_alv,
  871.     l_archiv_doc_id TYPE sapb-sapadokid,
  872.     l_archiv_id     TYPE toaar-archiv_id,
  873.     s_toa           TYPE ty_toaxx,
  874.     t_comp          TYPE TABLE OF components,
  875.     s_comp          TYPE components,
  876.     l_document_type TYPE sapb-sapdoktyp.
  877.  
  878.  
  879.   LOOP AT it_toa INTO s_toa.
  880.  
  881.     CLEAR s_alv.
  882.  
  883.     s_alv-reltype = 'ALINK'.
  884.  
  885.     PERFORM read_arobject_text CHANGING s_toa  s_alv.
  886.  
  887.     s_alv-instid_a = s_toa-object_id.
  888.     s_alv-typeid_a = s_toa-sap_object.
  889.     s_alv-phio_id = s_toa-arc_doc_id.
  890.     s_alv-stor_cat = s_toa-archiv_id.
  891.  
  892.  
  893.     l_archiv_doc_id = s_toa-arc_doc_id.
  894.     l_archiv_id = s_toa-archiv_id.
  895.     REFRESH t_comp.
  896.     CALL FUNCTION 'ARCHIVOBJECT_STATUS'
  897.       EXPORTING
  898.         archiv_doc_id            = l_archiv_doc_id
  899.         archiv_id                = l_archiv_id
  900. *       SIGN                     = ' '
  901. *       DOC_TYPE                 = ' '
  902. *       SIGNATURE                = 'X'
  903.       IMPORTING
  904. *       ARCHIV_OBJECT_STATUS     =
  905. *       AR_DATE                  =
  906. *       AR_TIME                  =
  907.         document_type            = l_document_type
  908.       TABLES
  909.         al_components            = t_comp
  910. *       COMPSL                   =
  911.       EXCEPTIONS
  912.         error_archiv             = 1
  913.         error_communicationtable = 2
  914.         error_kernel             = 3
  915.         OTHERS                   = 4.
  916.  
  917.     IF sy-subrc <> 0.
  918.     ENDIF.
  919.  
  920.     LOOP AT t_comp INTO s_comp.
  921.       s_alv-file_name = s_comp-compid.
  922.       s_alv-mimetype = s_comp-mimetype.
  923.       s_alv-file_size = s_comp-compsize.
  924.       s_alv-doc_format = l_document_type.
  925.       APPEND s_alv TO it_data.
  926.     ENDLOOP.
  927.  
  928.  
  929.  
  930. FORM read_arobject_text CHANGING s_toa TYPE ty_toaxx s_alv TYPE zar_gos_atta_alv.
  931.   STATICS: xtext TYPE toasp-objecttext,
  932.            xtoa  TYPE ty_toaxx.
  933.  
  934.   IF xtoa-ar_object = s_toa-ar_object.
  935.     s_alv-stext = xtext.
  936.   ELSE.
  937.     SELECT SINGLE objecttext FROM toasp INTO s_alv-stext WHERE
  938.       ar_object =  s_toa-ar_object AND
  939.       language = sy-langu.
  940.     xtext = s_alv-stext.
  941.     xtoa = s_toa.
  942.   ENDIF.
  943.  
  944.  
  945.  
  946. FORM getdoc_alink.
  947.  
  948.  
  949.   DATA l_path TYPE char255.
  950.   DATA l_dir TYPE string.
  951.   DATA l_rc TYPE i.
  952.   DATA ls_comps TYPE scms_stinf.
  953.   DATA lt_comps TYPE TABLE OF scms_stinf.
  954.   DATA l_stor_cat TYPE  sdokstca-stor_cat VALUE space.
  955.   DATA l_filename TYPE  sdok_filnm VALUE space.
  956.  
  957.   PERFORM checkpath.
  958.  
  959.   CONCATENATE p_path '\' <p>-phio_id '\' <p>-instid_a '.' <p>-doc_format INTO l_path.
  960.  
  961.  
  962.  
  963.   CALL FUNCTION 'SCMS_DOC_READ_FILE'
  964.     EXPORTING
  965. *     MANDT                 = SY-MANDT
  966.       stor_cat              = l_stor_cat
  967.       crep_id               = <p>-stor_cat
  968.       doc_id                = <p>-phio_id
  969. *     PHIO_ID               =
  970.       comp_id               = <p>-file_name
  971.       path                  = l_path
  972. *     FRONTEND              = 'X'
  973. *     SIGNATURE             = 'X'
  974.       security              = ' '
  975. *     NO_CACHE              = ' '
  976. *     P_TRANSFER_PHIO       =
  977. * IMPORTING
  978. *     SIZE                  =
  979. *     MIMETYPE              =
  980.     EXCEPTIONS
  981.       bad_storage_type      = 1
  982.       bad_request           = 2
  983.       unauthorized          = 3
  984.       not_found             = 4
  985.       conflict              = 5
  986.       internal_server_error = 6
  987.       error_http            = 7
  988.       error_signature       = 8
  989.       error_config          = 9
  990.       error_hierarchy       = 10
  991.       error_format          = 11
  992.       error_open            = 12
  993.       error_download        = 13
  994.       error_parameter       = 14
  995.       error                 = 15
  996.       OTHERS                = 16.
  997.  
  998.   IF sy-subrc <> 0.
  999. *    in case of filename problems
  1000.  
  1001.  
  1002.     CALL FUNCTION 'SCMS_DOC_READ_FILE'
  1003.       EXPORTING
  1004. *       MANDT                 = SY-MANDT
  1005.         stor_cat              = l_stor_cat
  1006.         crep_id               = <p>-stor_cat
  1007.         doc_id                = <p>-phio_id
  1008. *       PHIO_ID               =
  1009.         comp_id               = l_filename
  1010.         path                  = l_path
  1011. *       FRONTEND              = 'X'
  1012. *       SIGNATURE             = 'X'
  1013.         security              = ' '
  1014. *       NO_CACHE              = ' '
  1015. *       P_TRANSFER_PHIO       =
  1016. * IMPORTING
  1017. *       SIZE                  =
  1018. *       MIMETYPE              =
  1019.       EXCEPTIONS
  1020.         bad_storage_type      = 1
  1021.         bad_request           = 2
  1022.         unauthorized          = 3
  1023.         not_found             = 4
  1024.         conflict              = 5
  1025.         internal_server_error = 6
  1026.         error_http            = 7
  1027.         error_signature       = 8
  1028.         error_config          = 9
  1029.         error_hierarchy       = 10
  1030.         error_format          = 11
  1031.         error_open            = 12
  1032.         error_download        = 13
  1033.         error_parameter       = 14
  1034.         error                 = 15
  1035.         OTHERS                = 16.
  1036.     IF sy-subrc <> 0.
  1037. *      logg ls-phio_id sy-subrc 'Download 2'.
  1038.       EXIT.
  1039.     ENDIF.
  1040.  
  1041.   ENDIF.
  1042.  
  1043.  
  1044. ENDFORM.                    "Getdoc
  1045.  
GeSHi ©


Additional
100.png
100.png (216.82 KiB) Viewed 623 times
Attachments
Z_AR_SGOS_DOWNLOAD.zip
(6.24 KiB) Downloaded 55 times
Tron
.....
.....
 
Posts: 1098
Joined: Sat Aug 04, 2007 10:21 pm

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest

cron
  • Latest Topics