on 02-19-2013 7:14 AM
Dear All,
While taking the Print of WCA automatically the Document which we attached using service objects in Functional Location or Equipment ( for which we create WCA) should also be printed .
Is it Possible?
Hi Pradeep,
Check out the following ABAP code. This will help you to access the attachments that are linked to your WCA objects. Modify your WCA print program and append the print program for these objects also. The below given program is also available on net. Pls modify according to your requirement.
Hope this solves.
Regards
Sathish
REPORT /ctac/ami_tool_down_attachmnts LINE-SIZE 1000.
TYPE-POOLS: abap, "ABAP reporting types / constantsicon. "Possible icons
TYPES: ty_fieldname(80) TYPE c. TYPES:BEGIN OF ts_key, foltp TYPE so_fol_tp, folyr TYPE so_fol_yr, folno TYPE so_fol_no, objtp TYPE so_obj_tp, objyr TYPE so_obj_yr, objno TYPE so_obj_no, forwarder TYPE so_usr_nam, END OF ts_key .
TYPES:BEGIN OF ts_attachment, foltp TYPE so_fol_tp, folyr TYPE so_fol_yr, folno TYPE so_fol_no, objtp TYPE so_obj_tp, objyr TYPE so_obj_yr, objno TYPE so_obj_no, brelguid TYPE oblguid32, roletype TYPE oblroltype, END OF ts_attachment .
TYPES:tt_attachment TYPE TABLE OF ts_attachment .
TABLES: soc3. "containsDATA: ta_srgbtbrel TYPE STANDARD TABLE OF srgbtbrel,wa_srgbtbrel TYPE srgbtbrel, wa_sood TYPE sood.
DATA:tp_path TYPE ty_fieldname VALUE 'FILENAME-FILEEXTERN'.
SELECT-OPTIONS: so_insti FOR wa_srgbtbrel-instid_a,so_typid FOR wa_srgbtbrel-typeid_a DEFAULT 'TRDIR', so_catid FOR wa_srgbtbrel-catid_a DEFAULT 'BO'.
PARAMETERS : pa_filty(3) TYPE c DEFAULT 'BIN' OBLIGATORY,pa_path LIKE (tp_path) OBLIGATORY.
START-OF-SELECTION.SELECT * FROM srgbtbrel INTO TABLE ta_srgbtbrel WHERE instid_a IN so_insti AND typeid_a IN so_typid AND catid_a IN so_catid.
IF sy-subrc eq 0. SORT ta_srgbtbrel BY instid_a typeid_a catid_a. DELETE ADJACENT DUPLICATES FROM ta_srgbtbrel COMPARING instid_a typeid_a catid_a.
LOOP AT ta_srgbtbrel INTO wa_srgbtbrel. PERFORM process_attachments USING wa_srgbtbrel-instid_a wa_srgbtbrel-typeid_a wa_srgbtbrel-catid_a. ENDLOOP. ENDIF.
END-OF-SELECTION.
FORM process_attachments USINGutp_instid TYPE any utp_typeid TYPE c utp_catid TYPE c.
DATA: lta_sood TYPE STANDARD TABLE OF sood, lwa_sood TYPE sood.
DATA: ltp_pathin(1000) type c, ltp_filename TYPE string.
DATA: ltp_sortfield TYPE char30. DATA: lta_objcont TYPE soli_tab. DATA: ltp_binfilesize LIKE soxwd-doc_length. DATA: lta_attachments TYPE tt_attachment, lwa_attachments LIKE LINE OF lta_attachments.
PERFORM get_item_links USING utp_instid utp_typeid utp_catid CHANGING lta_attachments.
CHECK LINES( lta_attachments ) > 0.
LOOP AT lta_attachments INTO lwa_attachments. WRITE: / utp_instid, utp_typeid, utp_catid .
CLEAR lta_sood[].
SELECT * FROM sood INTO TABLE lta_sood WHERE objtp = lwa_attachments-objtp AND objyr = lwa_attachments-objyr AND objno = lwa_attachments-objno.
LOOP AT lta_sood INTO lwa_sood. ltp_pathin = pa_path. ltp_binfilesize = wa_sood-objlen.
WRITE: lwa_sood-objtp, lwa_sood-objyr, lwa_sood-objno.
CONCATENATE lwa_sood-objtp lwa_sood-objyr lwa_sood-objno INTO ltp_sortfield.
IMPORT
objcont_tab TO lta_objcont
FROM DATABASE soc3(dt) ID ltp_sortfield.
IF sy-subrc = 0.
CONCATENATE ltp_pathin '\' utp_typeid '_' utp_instid '_' lwa_sood-objdes '.' lwa_sood-file_ext INTO ltp_pathin.
REPLACE '\\' WITH '\' INTO ltp_pathin+2. TRANSLATE ltp_pathin USING '/ '.
CALL FUNCTION 'SO_OBJECT_DOWNLOAD' EXPORTING bin_filesize = ltp_binfilesize default_filename = filetype = pa_filty path_and_file = ltp_pathin extct = lwa_sood-extct no_dialog = 'X'
IMPORTING
act_filename = ltp_filename TABLES objcont = lta_objcont EXCEPTIONS file_write_error = 1 invalid_type = 2 x_error = 3 kpro_error = 4 OTHERS = 5 . IF sy-subrc <> 0. WRITE: 'Error Download'(e02), sy-msgid , sy-msgty, sy-msgno, sy-msgv1, sy-msgv2, sy-msgv3, sy-msgv4. ELSE. WRITE: 'OK download'(e01), ltp_filename. ENDIF. ELSE. WRITE: 'Error download'(e02), ltp_sortfield. ENDIF. ENDLOOP. ENDLOOP.
ENDFORM. "process_attachments
FORM get_item_links USING utp_instid TYPE anyutp_typeid TYPE c utp_catid TYPE cCHANGING
cta_attachments TYPE tt_attachment.
DATA: lo_boritem TYPE REF TO cl_sobl_bor_item, lo_al_item TYPE REF TO cl_gos_al_item, li_link TYPE REF TO if_browser_link, ls_option TYPE obl_s_relt, lt_options TYPE obl_t_relt, ls_key TYPE ts_key, ls_attachment TYPE ts_attachment, lt_attachment TYPE tt_attachment, lt_links TYPE obl_t_link, ls_link TYPE obl_s_link, lp_linkid TYPE blnk_inst.
DATA: gs_lpor TYPE sibflporb.
CLEAR cta_attachments[].
gs_lpor-instid = utp_instid. gs_lpor-typeid = utp_typeid. gs_lpor-catid = utp_catid.
ls_option-sign = 'I'. ls_option-option = 'EQ'.
ls_option-low = 'ATTA'. APPEND ls_option TO lt_options.
ls_option-low = 'NOTE'. APPEND ls_option TO lt_options.
ls_option-low = 'URL'. APPEND ls_option TO lt_options.
TRY. CALL METHOD cl_binary_relation=>read_links_of_binrels EXPORTING is_object = gs_lpor it_relation_options = lt_options ip_role = 'GOSAPPLOBJ' ip_no_buffer = IMPORTING et_links = lt_links. . LOOP AT lt_links INTO ls_link. CASE ls_link-typeid_b . WHEN 'MESSAGE'. ls_key = ls_link-instid_b. MOVE-CORRESPONDING ls_key TO ls_attachment. ls_attachment-roletype = ls_link-roletype_b. IF ls_link-brelguid IS INITIAL. ls_attachment-brelguid = ls_link-relguidold. ELSE. ls_attachment-brelguid = ls_link-brelguid. ENDIF. APPEND ls_attachment TO lt_attachment.
WHEN OTHERS. CONTINUE. ENDCASE. ENDLOOP.
IF sy-subrc = 0.
ENDIF. CATCH cx_obl_parameter_error . CATCH cx_obl_internal_error . CATCH cx_obl_model_error . CATCH cx_root. ENDTRY.
cta_attachments[] = lt_attachment[].
ENDFORM. "get_item_links
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is not possible with standard SAP print functionality.
You may need to go for some third party tool support. You search for Prometheus tool.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.