Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in Document flow from material to purchase requisitions

Former Member
0 Kudos

Hi,

I created a document via CV01N and attached the same in material master(Material A) - document data. Now I am creating a purchase Requisition for Material A, how is it possible to make the system to automatically picks the document from material master & attach it to Purchase Requisition for Material-A rather than attaching again in purchase requisition??

I have written a Code as below:

FUNCTION ZTEST_MV.*"----------------------------------------------------------------------*"*"Local Interface:*"----------------------------------------------------------------------
DATA: lv_objkey TYPE drad-objky,
lv_NEW_objkey TYPE drad-objky,
i_drad TYPE TABLE OF drad,
i_dradn TYPE TABLE OF drad_n,
w_drad TYPE drad,
w_dradn TYPE drad_n.
lv_OBJKEY = 'CO2005BNW'.
CHECK lv_objkey IS NOT INITIAL.
* Get the Document key#s of MARA
CALL FUNCTION 'DOKUMENTE_ZU_OBJEKT'EXPORTINGkey = lv_objkey
objekt = 'MARA'TABLES
doktab = i_dradEXCEPTIONS
kein_dokument = 1OTHERS = 2.
BREAK-POINT.
CONCATENATE '3000004143' '0010' INTO lv_new_objkey.** Populate i_dradn itab from i_drad*LOOP AT i_drad INTO w_drad.*** Assign MARA document to PR Item*MOVE-CORRESPONDING w_drad TO w_dradn.*
w_dradn-dokob = 'EBAN'.*
w_dradn-objky = lv_new_objkey.*APPEND w_dradn TO i_dradn.*ENDLOOP.***CHECK i_dradn[] IS NOT INITIAL.*** Map the MARA document key to PR Line Item*CALL FUNCTION 'DOKUMENTZUORDNUNGEN_BUCHEN'* IN UPDATE TASKEXPORTING
ob = 'EBAN'
objky = lv_new_objkeyTABLES
savdrad = i_dradn.***** Commit the changes*CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGwait = 'X'.
ENDFUNCTION.

The above Code is not giving any error but it is not doing the needful also i.e.: attaching the document from Material to PR Line Item.

Please suggest a solution on the same if anyone has worked on such issue.

Regards,

0 REPLIES 0