09-12-2016 2:18 PM
Hi Experts,
I have a custom report which displays the vendor confirmations as ALV GRID display for the Purchase order numbers mentioned in the selection screen.
Now my requirement is I will select one line at the report output and I want to add attachment to the PO from the vendor confirmation report, Coud you please suggest on achieving this requirement. I came across table SRGBTBREL table and INSTID_A holds the value of the PO nos .
Thanks,
RG
09-13-2016 1:24 PM
Hi.
You should perform this sequence of function calls:
- SO_FOLDER_ROOT_ID_GET' to set folder ID;
- SO_OBJECT_INSERTto insert your document converted with SO_CONVERT_CONTENTS_BIN';
- BINARY_RELATION_CREATE_COMMIT to finally register your attachment.
Hope to help
Bye
09-13-2016 1:24 PM
Hi.
You should perform this sequence of function calls:
- SO_FOLDER_ROOT_ID_GET' to set folder ID;
- SO_OBJECT_INSERTto insert your document converted with SO_CONVERT_CONTENTS_BIN';
- BINARY_RELATION_CREATE_COMMIT to finally register your attachment.
Hope to help
Bye
09-13-2016 1:52 PM
Yes. He is Roberto Vacca correct . I am also searching for this one
You can run the below code, Just give the Client , po number and select path from the Desktop.
And file name it will be Created automatically.
TYPES : BEGIN OF ty_table, "Structure for FileName
fname(128) TYPE c,
END OF ty_table.
*Data Declarations
DATA: w_prog TYPE sy-repid, "Current Program Name
w_dynnr TYPE sy-dynnr, "Current Dynpro Number
w_attachement TYPE borident, "Work Area for BOR object identifier
ws_borident TYPE borident, "Work Area for BOR object identifier
w_document TYPE sood4, "Interface for send screen and MOM
folder_id TYPE soodk, "Definition of Object Key
w_h_data TYPE sood2, "Object Definition Workarea
w_fol_data TYPE sofm2, "Folder Contents Work area
w_rec_data TYPE soos6, "Transfer Information of folder Work area
ws_files TYPE ty_table,
wt_files TYPE TABLE OF ty_table.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*Parameter Declarations
PARAMETER: p_mandt TYPE sy-mandt, " Client Number
p_vbeln TYPE ebeln, " Sales Order Number
p_path TYPE ibipparms-path MEMORY ID ad_local_path, " File Path
p_name(30). " Name of attachement.
SELECTION-SCREEN END OF BLOCK b1.
*Initialization Event
INITIALIZATION .
w_prog = sy-repid .
w_dynnr = sy-dynnr .
*/ Selection Screen For File Path Selection
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path .
*/ F4 Help for file selection
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = w_prog
dynpro_number = w_dynnr
field_name = 'P_PATH'
IMPORTING
file_name = p_path.
*Start of selection Evvent
START-OF-SELECTION .
*/Client Validations
IF sy-mandt NE p_mandt .
WRITE 'Mandt Error' .
EXIT .
ENDIF .
*/ Assign Object Keys to the Structure BOR
ws_borident-objkey = p_vbeln. "SalesOrder Number
" ws_borident-objtype = 'EQUI'. "Object Type
ws_borident-objtype = 'BUS2012'."'BUS2032'. "BUS Number
*/ Filename Assign to the Structure
ws_files-fname = p_path . "Path
APPEND ws_files TO wt_files .
*/ Folder Root
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = folder_id
EXCEPTIONS
OTHERS = 1.
*/ Append data to the MOM Structure
w_document-foltp = folder_id-objtp.
w_document-folyr = folder_id-objyr .
w_document-folno = folder_id-objno .
w_document-objdes = p_name . "Name of file
w_document-objnam = p_name . "Name of file
*/ Attachment FileName Assignment
w_h_data-objdes = p_name . "Name of file
*/ Using this function module to read FILE from Presentation server
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = 'IMPORTFROMPC'
ref_document = w_document
TABLES
files = wt_files
CHANGING
document = w_document
header_data = w_h_data
folmem_data = w_fol_data
receive_data = w_rec_data.
*/ File Creation OkCodes
IF w_document-okcode = 'CREA' OR w_document-okcode = 'CHNG'.
w_attachement-objtype = 'MESSAGE'.
w_attachement-objkey = w_document(34).
CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
EXPORTING
obj_rolea = ws_borident
obj_roleb = w_attachement
relationtype = 'ATTA'
EXCEPTIONS
no_model = 1
internal_error = 2
unknown = 3
OTHERS = 4.
*/Error Handling
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF .
BREAK-POINT.
09-15-2016 10:27 AM
Hello Vacca & NewB To Abap,
thank you very much for your replies.
I want to add file from the list output of the report,
But the call Function F4_FILE_NAME is used to add documents at the selection screen, I need to add attachments at the list window output, please let me know if you know any function modules that can be used to attach files from report output ie at the list window.
Thanks,
RG
09-15-2016 10:39 AM
understood your problem, may i know i hope you are using report. Which report alv , or else with alv with opps concent.
09-15-2016 11:08 AM
If you use Normal Alv. I will give you one solution.
Normally in alv by using 'USER_COMMAND' We are proving Actions to the end users like
open the particular screen after click on the Each row.
In one of the column you just ask them to double click . then
File open dialog ,User has to pick the file from the desk top. v_filename this will give you the
selected file path update this value to the to internal table. then Ask them to press any update button at Toolbar then New values will be show into alv, For updating the selected path.
Delete button for removing the path text from the each of the alv.
Hope you understood.
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
DATA:sel_fold TYPE string.
CASE rs-fieldname .
WHEN 'BANFN'.
BREAK-POINT.
DATA: l_filetable TYPE filetable,
l_rc TYPE i.
DATA: v_filename TYPE string. "FOR HOLDING FILENAME.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = 'C:\zch_pid.txt'
CHANGING
file_table = l_filetable
rc = l_rc.
READ TABLE l_filetable INTO v_filename INDEX 1.
endform.
09-15-2016 11:08 AM
Hi ,
I am using normal ALV report REUSE_ALV_GRID_DISPLAY to display the output.
Thanks,
RG
09-15-2016 11:10 AM
09-15-2016 11:58 AM
Thank you very much NewB To Abap, the above method worked to upload file from the list window
Could you please clarify one more thing
ws_borident-objkey = p_vbeln. "SalesOrder Number
" ws_borident-objtype = 'EQUI'. "Object Type
ws_borident-objtype = 'BUS2012'."'BUS2032'. "BUS Number
here I am trying to upload a file to PO so the objkey would be PO no and objtype would be ?????
what is the BUS Number that I should use ?
Thanks,
RG
09-15-2016 12:08 PM
Actually I don't know much about object type , but if you ignore also it will be work.
Regarding Bus number ws_borident-objtype = 'BUS2012'
I have some knowledge. In Sap each Screen is having one object that is nothing but Bus number.
Here BUS2012 nothing but it is belongs to Purchase order
In the table TOJTB You can check the Object or Busnumber and Object name (purchase order)
And one more thing copy past the bus number BUS2012 and open the T code SWO1 and execute it.
It will show the list of information related to the Purchase order.
I hope you aware of this one , some knowledge you have. you faced the problem while creating the custom object.
Hope you understood.
09-15-2016 12:16 PM
If it is Useful Try to close the post. It will be useful to others.
09-15-2016 4:03 PM