Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Firoz_Ashraf
Contributor


Requirement:

For a specific DMS Object type, we need to populate the dependent objects automatically while creating the document from transaction CV01N.

We will take the example of a document type ZZZ which has the following objects:

  1. Purchase Order Item.

  2. Purchase Requisition.

  3. Material.

  4. Vendor




We want that whenever user creates a document in CV01N and when he enters the PO number, the corresponding data for PR, Material and vendor should get populated automatically in their respective tabs instead of entering them manually.



Solution:

We need to find an explicit enhancement in function group CV130 at specific point.

In this case since PO is the master object and PR, Material & Vendor are dependent we need to find enhancement point in PO object.

So, we found our explicit enhancement point at the end of FORM save_intrad_in_gt_drad in INCLUDE LCV130F04.

ENHANCEMENT 1 ZATG_AUTOFILL_PR_MATNR. "active version
*************ATG Change (By Firoz Ashraf)***************
CHECK sy-tcode = 'CV01N'.
DATA: wa_drad LIKE LINE OF intdrad,
wa_dradnew LIKE LINE OF intdrad,
v_matnr TYPE matnr,
v_ponum TYPE ebeln, v_poitm TYPE ebelp,
v_prnum TYPE banfn, v_pritm TYPE bnfpo,
v_lifnr type ELIFN.
READ TABLE gt_drad INTO wa_drad INDEX 1.
IF sy-subrc = 0.
wa_dradnew = wa_drad.
CHECK wa_drad-dokar = 'ZZZ'.
v_ponum = wa_drad-objky(10).
v_poitm = wa_drad-objky+10(5).
******Material Master
READ TABLE gt_drad WITH KEY dokob = 'MARA'.
IF sy-subrc NE 0.
SELECT SINGLE matnr FROM ekpo
INTO v_matnr
WHERE ebeln = v_ponum AND ebelp = v_poitm.
IF NOT v_matnr IS INITIAL.
wa_dradnew-dokob = 'MARA'.
wa_dradnew-objky = v_matnr.
APPEND wa_dradnew TO gt_drad.
ENDIF.
ENDIF.
******Purchase req. item
READ TABLE gt_drad WITH KEY dokob = 'EBAN'.
IF sy-subrc NE 0.
SELECT SINGLE banfn bnfpo FROM ekpo
INTO (v_prnum, v_pritm)
WHERE ebeln = v_ponum AND ebelp = v_poitm.
IF NOT v_prnum IS INITIAL.
wa_dradnew-dokob = 'EBAN'.
CONCATENATE v_prnum v_pritm INTO wa_dradnew-objky.
APPEND wa_dradnew TO gt_drad.
ENDIF.
ENDIF.
******Vendor
READ TABLE gt_drad WITH KEY dokob = 'LFA1'.
IF sy-subrc NE 0.
SELECT SINGLE lifnr FROM ekko
INTO v_lifnr
WHERE ebeln = v_ponum.
IF NOT v_lifnr IS INITIAL.
wa_dradnew-dokob = 'LFA1'.
wa_dradnew-objky = v_lifnr.
APPEND wa_dradnew TO gt_drad.
ENDIF.
ENDIF.
ENDIF.
ENDENHANCEMENT.



Once you have done the above coding then the PR, Material & Vendor tab will get populated automatically with the relevant documents numbers related to the corresponding PO.





Note that this coding is just for reference and applicable only for one line in CV01N. You need to adjust it accordingly if you need multiple lines.

Regards,

Firoz.

Labels in this area