08-08-2012 7:20 AM
Guys,
My requirement is as follows: Multiple lines in an ALV will be selected and in the popup one file will be selected, then the file
must be attached to the key rows. The steps of Business object creation and assigning key fields are over, file gets attached successfully.
I cannot use the below code because the file open dialog opens up for every record selected.
loop at rows into wa_row.
read table it into wa index wa_row-index.
check sy-subrc = 0.
obj_bori-objkey = wa-inumber.
obj_bori-objtype = 'ZGOS'.
call method manager->start_service_direct
exporting
ip_service = 'PCATTA_CREA'
is_object = obj_bori.
endloop.
So I debugged the method start_service_direct and found out a class CL_GOS_SRV_ATTACHMENT_CREATE which gets called internally and took the code as below:
call function 'SO_FOLDER_ROOT_ID_GET'
exporting
region = 'B'
importing
folder_id = folder_id
exceptions
others = 0.
document-foltp = folder_id-foltp.
document-folyr = folder_id-folyr.
document-folno = folder_id-folno.
append document to documents.
clear documents[].
call function 'SO_DOCUMENTS_MANAGER'
exporting
activity = 'IMPO'
tables
documents = documents.
read table documents index 1 into document.
check sy-subrc = 0.
loop at rows into wa_row.
read table it into wa index wa_row-index.
check sy-subrc = 0.
obj_bori-objkey = wa-inumber.
obj_bori-objtype = 'ZGOS'.
if document-okcode = 'CREA'.
attachment-objtype = 'MESSAGE'.
attachment-objkey = document(34).
call function 'BINARY_RELATION_CREATE'
exporting
obj_rolea = obj_bori
obj_roleb = attachment
relationtype = 'ATTA'
exceptions
others = 1.
if sy-subrc = 0.
commit work.
endif.
endif.
endloop.
The second part is working very fine, but the problem I am facing is suppose I selected a line in ALV and clicked
attach button,choosed a file,done-its working. Now staying in the same ALV screen and again if I select the same line and choose another file
then it displays a windows popup "saying file XXX exits..do you want to replace it " which is wrong( It must attach actually ).
Anybody have any better idea to attach file for multiple items with just one "choose file dialog" popup ?
Regards
Kesavadas T
08-08-2012 7:55 AM
Hi Kesavadas,
This looks to be in the wrong order:
document-foltp = folder_id-foltp.
document-folyr = folder_id-folyr.
document-folno = folder_id-folno.
append document to documents.
clear documents[].
You clear the itab after you have added the folder informations.
Regards
Hendrik Maas
08-08-2012 7:55 AM
Hi Kesavadas,
This looks to be in the wrong order:
document-foltp = folder_id-foltp.
document-folyr = folder_id-folyr.
document-folno = folder_id-folno.
append document to documents.
clear documents[].
You clear the itab after you have added the folder informations.
Regards
Hendrik Maas
08-08-2012 8:01 AM
Thanks Jan,
I feel silly about myself .
I was debugging the SO_DOCUMENT_VIEW_MANAGER and line 463 where the ok_code gets changed to EXPO, so the message appears and I was trying to know why it was happening.