Sei sulla pagina 1di 15

Attachment Transfer from ECC PR to SRM

Situation:
Material, Service & Limit item procurement in Extended Classic Scenario are intended to transferred thru
RFC route

Requirement:
Quotes from the Supplier has to be attached as a reference document while Buyer sends a PO
Craftsmen have to use the exploded view diagram from the manufacturer to find the item they need
Technical Documents/Drawings that have to be attached to the ECC PR

Challenges:
Only ECC PR can be transferred thru BBP_EXTREQ_TRANSFER
There is no SC header therefore PR Header attachments cannot be seen in the SC header
Hence PR Header attachments have to be attached to the SC first Line Item


Methods:

DMS (Document Management Server)
GOS (General Object Service)
DMS & GOS for attachment transfer
http://www.sapfans.com/forums/viewtopic.php?f=12&t=349621

Recommendation:

Scenario: One wants to transfer a PR header attachment from ECC to SRM Shopping Cart.

This blog shows how to transfer header attachments from PR to SRM SC when--

1. PR header attachments are Service (GOS) and NOT DMS.

2. Report BBP_EXTREQ_TRANSFER is used to send PR to SRM.

Since there is no concept of attachment at SC header we will attach the PR header attachments to first item of SC.

Step1--> Fetch the attachment data in ERP systems as explained below.

Create an RFC enabled function module in back end system with following interface:

Importing Parameters:


Exporting Parameters:
Attachment Transfer from ECC PR to SRM




Source Code of Function Module:

**conversion declaration
DATA: lv_codep TYPE cpnormcp,
lo_conu TYPE REF TO cl_abap_conv_uc_number.


DATA: lt_asci_list TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_conhex TYPE solix OCCURS 1 WITH HEADER LINE,
lv_inp TYPE string,
lv_ous TYPE xstring,
lv_len TYPE i.
**End
DATA: lo_is_object_a TYPE sibflporb.
DATA: lt_rel TYPE obl_t_relt,
wa_rel LIKE LINE OF lt_rel.


DATA: lt_links TYPE obl_t_link,
lw_links TYPE obl_s_link,
lv_document_id TYPE so_entryid,
ls_data TYPE sofolenti1.
DATA lt_content TYPE swuoconttab.


lo_is_object_a-typeid = 'BUS2105'.
lo_is_object_a-catid = 'BO' .
lo_is_object_a-instid = p_bo_id .




wa_rel-sign = 'I'.
wa_rel-option = 'EQ'.
wa_rel-low = 'ATTA' .
APPEND wa_rel TO lt_rel.


TRY.
Attachment Transfer from ECC PR to SRM

CALL METHOD cl_binary_relation=>read_links
EXPORTING
is_object = lo_is_object_a
it_relation_options = lt_rel
IMPORTING
et_links = lt_links.


CATCH cx_obl_parameter_error .
CATCH cx_obl_internal_error .
CATCH cx_obl_model_error .
ENDTRY.






* DESCRIBE TABLE lt_links LINES ev_records.


* LT_LINKS contains one record for each attachment at header
* Read all attachments one by one
* In case of text files table it_solix(binary) is initial after below FM call but lt_asci_list is populated with CHAR
format string passing this directly as *export/table parameter to the calling system(SRM)causes dump
PARAMETER_CONVERSION_ERROR in calling system so alwasy convert the *CHAR strinh into Binary data before
sending to calling system


READ TABLE lt_links INTO lw_links INDEX iv_read_index.


IF sy-subrc = 0.
lv_document_id = lw_links-instid_b .


CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = lv_document_id
IMPORTING
document_data = ls_data
TABLES
object_content = lt_asci_list
contents_hex = it_solix
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.


es_data = ls_data.

Attachment Transfer from ECC PR to SRM


* In case converting CHAR string to Binary data for sending to calling system


IF NOT lt_asci_list[] IS INITIAL.
CALL FUNCTION 'SYSTEM_CODEPAGE' "get the current code page
IMPORTING
codepage = lv_codep
.


CREATE OBJECT lo_conu "instantiate cl_abap_conv_uc_number
EXPORTING
im_source_codepage = lv_codep
EXCEPTIONS
converter_creation_failed = 1
OTHERS = 2.


LOOP AT lt_asci_list.
WRITE cl_abap_char_utilities=>cr_lf TO lt_asci_list-line+253. "to put linefeed at end
MOVE lt_asci_list-line TO lv_inp. "move char to input string
CALL METHOD lo_conu->convert_char_stream "call method to convert
EXPORTING
im_stream = lv_inp
IMPORTING
ex_stream = lv_ous
ex_stream_len = lv_len
EXCEPTIONS
conversion_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
CONTINUE. "if error in conversion than do no append to table
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
MOVE lv_ous TO lt_conhex-line. "move the binary string to binary table
APPEND lt_conhex.
ENDIF.
ENDLOOP.


it_content[] = lt_conhex[].


ENDIF.
ELSE.
ev_exit = 'X'.
ENDIF.
* ENDLOOP.


ENDFUNCTION.
Attachment Transfer from ECC PR to SRM



Step2--> Changes on SRM Side

Create a new function module in SRM as shown below:

Importing Parameter:



Exporting Parameter:



Source Code of Function Module:

DATA: is_data TYPE sofolenti1,
it_content TYPE tabtype_solix,
it_solix TYPE tabtype_solix,
ls_attach TYPE bbps_pdext_attach,
ls_sdokfext_c TYPE sdokfext_c,
ls_sdokfext TYPE sdokfext .


DATA: lv_pr_no TYPE char10 ,
lv_logsys TYPE char10,
iv_exit TYPE flag,
ev_read_index TYPE i VALUE 1,
lv_xstring TYPE xstring.


FIELD-SYMBOLS: <fs_hdr> TYPE any,
<fs_pr_no> TYPE any,
<fs_logsys> TYPE any.





Attachment Transfer from ECC PR to SRM


* Get PR no.
ASSIGN i_header TO <fs_hdr>.
ASSIGN COMPONENT 'EXT_DEMID' OF STRUCTURE
<fs_hdr> TO <fs_pr_no>.
lv_pr_no = <fs_pr_no>.


* Get Logical system
ASSIGN COMPONENT 'EXT_DEM_LOGSYS' OF STRUCTURE
<fs_hdr> TO <fs_logsys>.
lv_logsys = <fs_logsys>.




WHILE iv_exit IS INITIAL.
**Fetch header attachments from Backend System
CALL FUNCTION 'RFC_CREATED_IN_BE_SYSTEM' DESTINATION lv_logsys
EXPORTING
p_bo_id = lv_pr_no
iv_read_index = ev_read_index
IMPORTING
es_data = is_data
it_content = it_content
it_solix = it_solix
ev_exit = iv_exit.


ev_read_index = ev_read_index + 1.

IF NOT is_data IS INITIAL.
ls_attach-guid = lv_pr_no.
ls_attach-p_guid = '0001'.
ls_attach-description = is_data-obj_descr.
* Get and set mime type
TRANSLATE is_data-obj_type TO LOWER CASE.
ls_attach-phio_ext = is_data-obj_type.
* Searching in customer defined mime types
CLEAR ls_sdokfext_c .
SELECT SINGLE * FROM sdokfext_c
INTO ls_sdokfext_c
WHERE extension = is_data-obj_type.


IF sy-subrc NE 0 OR ls_sdokfext_c-type IS INITIAL.
* Searching in default mime types
CLEAR ls_sdokfext .
SELECT SINGLE * FROM sdokfext
INTO ls_sdokfext
WHERE extension = is_data-obj_type.
IF sy-subrc NE 0 OR ls_sdokfext-type IS INITIAL.
* no mime type found - assigning default mime type
Attachment Transfer from ECC PR to SRM

ls_attach-phio_mime = 'application/octetstream'.
ELSE.
ls_attach-phio_mime = ls_sdokfext-type.
ENDIF.
ELSE.
ls_attach-phio_mime = ls_sdokfext_c-type.
ENDIF.


ls_attach-phio_fname = is_data-obj_descr.
ls_attach-phio_ps_mime = is_data-obj_descr.
ls_attach-phio_fsize = is_data-doc_size.
ls_attach-phio_fsize = is_data-doc_size.




**convert SOLIX to XSTRING
IF NOT it_solix IS INITIAL.
CALL METHOD cl_bcs_convert=>solix_to_xstring
EXPORTING
it_solix = it_solix
* iv_size =
RECEIVING
ev_xstring = lv_xstring.


ELSEIF NOT it_content IS INITIAL."for text files it_solix is initial and it_content has converted binary data
CALL METHOD cl_bcs_convert=>solix_to_xstring
EXPORTING
it_solix = it_content
* iv_size =
RECEIVING
ev_xstring = lv_xstring.
ENDIF.


CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring
TABLES
binary_tab = ls_attach-phio_content.
APPEND ls_attach TO et_attach.
ENDIF.
ENDWHILE.


ENDFUNCTION.



Attachment Transfer from ECC PR to SRM

Standard function module BBP_BD_PDDOC_FROM_BAPI_MAPS is called on SRM side when transferring PR uses
BBP_EXTREQ_TRANSFER

Enhance function module BBP_BD_PDDOC_FROM_BAPI_MAPS at end.



We check the call stack to ensure that the FM is called by BBP_EXTREQ_TRANSFER only and not in any other
process.

IF SY_SUBRC = 0.

CALL FUNCTION 'FM_CREATED_IN_SRM_SYSTEM'
EXPORTING
I_HEADER = IS_HEADER <--Already there in FM BBP_BD_PDDOC_FROM_BAPI_MAPS
IT_ITEMS = IT_ITEMS <--Already there in FM BBP_BD_PDDOC_FROM_BAPI_MAPS

IMPORTING
ET_ATTACH = ET_ATTACH <--Already there in FM BBP_BD_PDDOC_FROM_BAPI_MAPS

ENDIF.

Source: http://scn.sap.com/community/srm/blog/2013/03/07/purchase-requisition-header-attachment-
transfer-to-srm-shopping-cart-first-item
Dated: 7
th
March 2013
Attachment Transfer from ECC PR to SRM



Following are the additional discussions from SCN:
#
We are customizing the plan-driven Procurement in SRM 5.5.

We implement badi in order to transfer Zfield from reservation (ECC document) to SC (SRM document). We want to
populate header SC data (table BBP_PDHGP).

In order to do it we have previously followed these steps:
1. We add zfields to HEADER_CUST_IMP structure
2. We add zfields to BBPS_ER_SC_HEADER_CUST_C structure

If we run program BBP_EXTREQ_TRANSFER in debugging mode, we find that the problem appears in
bapi BBP_BD_PDDOC_FROM_BAPI_MAPS. Structures IS_HEADER and IS_HEADER_CUST are populated
correctly, but ES_HEADER is only filled up with IS_HEADER information, but not with IS_HEADER_CUST data.

If the zfield is not passed from R/3 to SRM,try this workaround:

Create the custom field in R/3 and populate the value for that field in R/3(manually/trhough transaction).

Instead of passing this field from R/3 to SRM,in SRM ,create a custom field at the SC header level(refer notes
672960 and 458591 ).Then in the badi "BBP_DOC_CHANGE_BADI",populate the value for that field using the SC
number. Pass the SC number to the FM "BBP_PD_SC_GETDETAIL" and in the table ET_ITEM,in the fiel
d"EXT_DEMID",you will get the backend reservation number from which this SC is created.Then make an RFC call
to the backend using the FM "BAPI_RESERVATION_GETDETAIL" and fetch the value of the custom field in the R/3
backend reservation and accordingly populate in the SRM custom field.A bit tedious method but will work!

-https://scn.sap.com/thread/1099988
#
If i understand your question correctly you want to transfer documents which are attached at the shopping cart
level in SRM to flow in to ECC at PR or PO level? If that the case following steps require to have documents flow
into ECC.

SRM Side:
Implement BADI BBP_CREATE_BE_RQ_NEW (If you are on classic scenario i.e. Shopping cart to PR creation) or
BBP_CREATE_BE_PO_NEW (For extended classic) with following code:

cs_ctrl_att-BE_DOC_TYPE = 'SRM'.
cs_ctrl_att-BE_storage_cat = 'DMS_C1_ST'.
cs_ctrl_att-TRANSFER_ACTIVE = 'X'.

ECC Side:
-Create a new document type for SRM with T. Code DC10. Following parameters need to be set for that
a. Check Use KPro
b. Check Version Assignment
c. Check Change Docs
d. Assign Internal number range as u201C02u201D and external number range as u201C01u201D
e. Select Number Exit u201CMCDOKZNRu201D
f. Version number increment u201C1u201D
g. File Size u201C10000000u201D
Attachment Transfer from ECC PR to SRM


- Assign following Object links to the new created document type u201CSRMu201D.
a. Type as u201CSRMu201D
b. Object as u201CEBANu201D and u201CEKPOu201D respectively
c. Object description as u201CPurchase req. itemu201D and u201CPurchase order itemu201D respectively
d. Screen number u201C247u201D for EBAN and u201C248u201D for EKPO.

- Request basis to verify DC30 transaction code that all the necessary document type are allowed to x'fer (i.e. .doc,
.xls , .jpg etc)

With this setting we were able to successfully transfer document from SRM side to ECC side
- https://scn.sap.com/thread/1276141
****

#
The usual procedure for integrating SRM AND DMS is as follows,

1.OAC0- Creation of the SAP Content Repository

a.ArchiveLink

b.HTTP Content Server

2 repositories were created one with a Document Area of Archive Link and another with a document area of DMS.

SRM will use the Content Repository with the DMS document area.

Maintain categories->
The storage category links the storage category with a content repository.

SRM will reference the storage category and from this configuration determine the storage location as a content
repository.


respect ur specific Q for other areas u will find while configuring cotent repositry.
1.u will find FTP wile u configuring ur content repository.

this is used for external file handling purpose.
- https://scn.sap.com/thread/1276141
****

#
I want open a document stored in DMS through RFC BAPI, from an external application (for example .NET)

EasyDNS run OK: I have included the bapi Z_EASYDMS_ECL_OPEN_DOCUMENT (code from a SAP note) in the
system and I can open ECL/EAI & local documents (pdf, word, ...)

If I run Z_EASYDMS_ECL_OPEN_DOCUMENT from SE37 run OK: I can see every document, document is
downloaded to local system and then open.
Attachment Transfer from ECC PR to SRM


But when I call bapi Z_EASYDMS_ECL_OPEN_DOCUMENT from my external application through RFC I don't receive
any result: document is not download to local system.

I have debugged the bapi (with SM50) and I have see that the calling entry in bapi, run and then ... crash.

I have detected the fail in OLE_FLUSH_CALL: system has a dump.

Summary:
- EasyDMS run Ok
- SE37 Z_EASYDMS_ECL_OPEN_DOCUMENT run ok
- Z_EASYDMS_ECL_OPEN_DOCUMENT dump at OLE_FLUSH_CALL

Any idea?
-http://scn.sap.com/thread/1233035
****

#
It is possible to extract DMS's file to application server directory:

FUNCTION Z_DMS_VIEW.
*"----

""Interfase local
*" IMPORTING
*" VALUE(DOC_NUMBER) LIKE BAPI_DOC_DRAW2-DOCUMENTNUMBER OPTIONAL
*" VALUE(DOC_PART) LIKE BAPI_DOC_DRAW2-DOCUMENTPART OPTIONAL
*" VALUE(DOC_TYPE) LIKE BAPI_DOC_DRAW2-DOCUMENTTYPE OPTIONAL
*" VALUE(DOC_VERS) LIKE BAPI_DOC_DRAW2-DOCUMENTVERSION OPTIONAL
*" VALUE(ORIGINAL_PATH) LIKE BAPI_DOC_AUX-FILENAME OPTIONAL
*" EXPORTING
*" VALUE(P_RETURN) LIKE BAPIRET2 STRUCTURE BAPIRET2
*" TABLES
*" DOC_FILES STRUCTURE BAPI_DOC_FILES2 OPTIONAL
*"----


CLEAR: doc_files.
REFRESH: doc_files.
DATA: i_doc_files like bapi_doc_files2.


DATA: i type i.
*
i = 2.
while i = 2.
i = 2.
endwhile.

CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW2'
EXPORTING
Attachment Transfer from ECC PR to SRM

DOCUMENTTYPE = DOC_TYPE
DOCUMENTNUMBER = DOC_NUMBER
DOCUMENTPART = DOC_PART
DOCUMENTVERSION = DOC_VERS
DOCUMENTFILE = i_doc_files
GETSTRUCTURE = '0'
GETCOMPONENTS = 'X'
ORIGINALPATH = ORIGINAL_PATH
HOSTNAME = ' '
GETHEADER = 'X'
PF_HTTP_DEST = 'SAPHTTPA'
PF_FTP_DEST = 'SAPFTPA'
IMPORTING
RETURN = P_RETURN
TABLES
DOCUMENTFILES = DOC_FILES.


ENDFUNCTION.

ORIGINAL_PATH must be a directory of application server.

By background is not possible (I don't know how can we do that) download this file to PC.

Then with the file in application server we can :

- to map application server directory in a drive unit of Pc
- to transfer with a ftp client from Pc
- rfcexec

But always the bapi can not download the file: it must be a process in Pc who transfer the file.
- http://scn.sap.com/thread/1233035

****
#
BADI BBP_CREATE_BE_RQ_NEW (in SRM)

you need to set attachement active with statement
CS_CTRL_ATT-TRANSFER_ACTIVE = 'X'.

BADI BBP_SC_TRANSFER_BE. Set CV_ATTCH_TRANSFER_ACTIVE paramater in SRM
Configure Document Type in R/3
- Transaction DC10 - Add a New Document Type SRM (if not already exists). Set 'Use KPro', 'Version Assign' and
'Change Docs'. Set the Internal and External Number Range (02 and 01). Use MCDOKZNR as Number Exit. Ver No.
Incr = 1 and Set the File Size (Usually 10000000 bytes).

Once the Document Type is created, define Object links to PO Item and Pur Req Item. Use - Screen Number 247
and Screen Number 248 with Valuation Object of EBAN and EKPO for Objects EBAN (PReq) and EKPO (PO) for Doc
Type SRM.

Attachment Transfer from ECC PR to SRM

3. Check whether you have all the workstation applications configured in R/3 (DOC, TXT, PDF, XLS etc) in
Transaction DC30.


Additional Checks:
- If you are transferring attachments and not link - make sure you have Implemented OSS Note: 820897 in R/3.

If the above settings does not give you results - you may want to debug and find out the exact error message while
creating the attachment.
- Check the R/3 Release and get the corresponding driver from BBP_FUNCTION_MAP table with Object Type as
DOCUMENT and Method - CreateFromData.
- Set the Breakpoint at Function Module BAPI_DOCUMENT_CREATE2 and at CVAPI_DOC_CHECKIN in the above
driver. These Function Modules will return you the exact error message.

-http://scn.sap.com/message/1155564#1155564
****
#

Attachment transfert to R/3 purchasing doc is now standard since SRM 4.0.
Your R/3 backend should be at least 46C.

It must be activated in BADI BBP_CREATE_REQ_BACK.
You must also specify backend content storage parameters in this BADI, based on the backend customizing of
DMS.

You can use the following parameters for transferring the attachements to the backend system:
CT_ATTACH_BE KW attachments including document
CV_ATTACH_BE_DOC_TYPE Document type (standard is SRM)
CV_ATTACH_BE_STORAGE_CAT Storage type (standard is DMS_C1_ST)
CV_ATTACH_TRANSFER_ACTIVE Activate transfer of attachments
CV_ATTACH_USE_URL Transfer URL only

Then during the PR creation, SRM uses META_ATTACHMENT_CREATE using previous parameters.
BAPI_DOCUMENT_CREATE2 will be called in R/3.
-http://scn.sap.com/message/1155564#1155564
To complete this integration I think you just need to Create your new External Repository 'ZA' in OAC0.

Then go in OACT and open BBPFILESYS. In Content Rep put 'ZA' our External Repository.
-http://scn.sap.com/thread/1270026
****
#
We had a similar situation where we had to switch the storage of attachments from SAP SRM server to Archive doc
server.
After making the switch we had to migrate the attachments from the old Shopping carts to the new Content
server.
to achieve this we executed a report RSIRPIRL via SA38. Here you would enter the Target and Source category,
Document area
Attachment Transfer from ECC PR to SRM

and PHIO class.
I know the response might be old and too late for you but still would like to log the info for the benefit of others in
the future.

- http://scn.sap.com/thread/1270026
****
# Configuring Attachment Transfer

Prerequisites
If you wish to store shopping cart attachments in the backend system, you must first activate the data transfer by
creating an active method in the BAdIs BBP_CREATE_BE_PO_NEW (for purchase orders) or
BBP_CREATE_BE_RQ_NEW (for purchase requisitions).
For more information, see the Implementation Guide (IMG) for Supplier Relationship Management: SRM Server
Business Add-Ins (BAdIs) Follow-On Document Generation in the Backend-System Purchase Order in Backend
System.
Or choose SRM Server Business Add-Ins (BAdIs) Follow-On Document Generation in the Backend-System
Purchase Requisition in Backend-System.
Procedure
You have to configure the R/3 Document Management System (DMS) in transaction DC10:
...
1. Create document type SRM. Note that no flag is set in any of the columns.
2. Double-click in the detail view to define the new Doc. type desc. = SRM Documents. Set the Use KPro
indicator.
Enter 1 in the Number assignment field.
Enter an internal number range interval. You can use an existing interval or create a new one in transaction
CV90. The internal number range must be used, because the GUID of the SRM attachments has more digits than
the number in the backend system.
Maintain the number exit. The number exit is a program exit for document numbers. It controls number
assignment and version numbering for documents. The default setting is MCDOKZNR. If you want to control the
number assignment or the version increment via a USER_EXIT, then you have to replace the program
MCDOKZNRwith a company-specific program. You can find further information in the field help for number exit.
In the screen area Field selection, enter u2013 in the Document Status field.
3. Go to the dialog structure and double-click the entry Define object links. Define the new object links EKPO
and EBAN. Maintain object link descriptions for EKPO (Purchase order item; Scr.no. 248) and EBAN (Purchase req.
item; Scr. no. 247)
4. Define the workstation application in transaction DC30.

All required file types should be included in this list.
- http://scn.sap.com/thread/1270026





Attachment Transfer from ECC PR to SRM

Relevant BAPI to attachments:
BBP_ATTACHMENT_FROM_EXT_MAPV Wertemapping Attachment extern nach intern
BBP_ATTACHMENT_IN_FROM_XI_MAPS Strukturmapping Attachment XI -> intern
BBP_ATTACHMENT_IN_MAPCB Common mapping for incoming attachments to BAPI
BBP_ATTACHMENT_OUT_MAPC Common mapping for outgoing attachment from BAPI
BBP_ATTACHMENT_OUT_MAPCB Common mapping for outgoing attachment from BAPI
BBP_ATTACHMENT_OUT_TO_XI_MAPS Strukturmapping Attachment intern -> XI
BBP_ATTACHMENT_TO_EXT_MAPV Wertemapping Attachment intern nach extern
http://www.conarum.com/srm/sap-srm-supplier-relationship-management-bausteine-bbp-a-bis-bbp-g

Potrebbero piacerti anche