Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

How to implement GOS for standard transaction VA01/VA02/VA03


 

Contents

  1. Problem Statement:


            1.1         Issue:

            1.2         Example.

            1.3         Resolution Approach:

  1. Process to be followed:


            2.1         Step 1:

            2.2         Step 2:

            2.3         Step 3:

            2.4         Step 4:

            2.5         Step 5:

  1. Steps to create attachments for Sales Order:


            3.1         Step 1:

            3.2         Step 2:

            3.3         Step 3:

            3.4         Step 4:

            3.5         Step 5:

            3.6         Step 6:

  1. Appendix. 1


1. Problem Statement:


There is a requirement of attaching supporting documents whenever business users will create new credit-memo or debit memo request (Sales Order) in SAP system through the transaction VA01. While attaching those supporting documents following challenge must occur:

1.1  Issue:


SAP standard supports create/change/display/delete of attachments on VA02 and VA03 (change and display sales order respectively) transactions with the help of value ‘X’ on parameter ‘SD_SWU_ACTIVE’. There is no provision to attach/view attachment while credit memo requests are being created. Objective of this RICEF is to enable this attachment functionality for ‘create’ transactions also.

 

1.2  Example


For the Sales Order Creation screen (VA01), the GOS tool bar is not provided by standard SAP.

See screen shot below:



We will see below how we can activate the GOS toolbar using above class for transactions VA01/VA02/VA03

1.3  Resolution Approach:


To resolve the above issue, we can use a SAP provided toolbar “Generic Object services” or “GOS toolbar”.

Following is the step by step instruction to use GOS Toolbar for resolving attachment issue.

 

2.  Process to be followed:


2.1 Step 1: To activate it we need to do an enhancement in include ‘SAPMV45A’ inside form SP_TAGGING.






2.2 Step 2: Object key is required to activate the generic object services. Now object types for corresponding sales orders are as below:

  • Credit memo request (VA01/VA02/VA03) -- BUS2094

  • Debit memo request (VA01/VA02/VA03) -- BUS2096

  • Sales Order (VA01/VA02/VA03) -- BUS2032




 

2.3 Step 3: The object key can be found out from the object type. Enter the object type in transaction ‘SWO1’

Click on display.



P.S: For above three Object types, object key is same and that is Sales Document.

 

2.4 Step 4: 

CL_GOS_MANAGER is a standard SAP class available within R/3 SAP systems depending on the version and release level. It is useful to manage attachments on a report. It lets you upload and download files related any object inside your report. To activate CL_GOS_MANAGER, we need to create instance of the class first. This instance can be created by calling a constructor method. In the constructor method code, object type and object key need to be set as variable and passed through instance of the class. The code needs to be written either inside above implicit enhancement point

Following is the syntax:

DATA:   lr_gos_manager TYPE REF TO cl_gos_manager,
             ls_borident    TYPE        borident.

STATICS lv_flag TYPE c.

  IF sy-tcode = 'VA01' AND lv_flag <> 'X'.
    CLEAR ls_borident.
    CASE vbak-vbtyp.
      WHEN 'K'.                               "Credit memo request
        ls_borident-objtype = 'BUS2094'.
      WHEN 'L'.                               "Debit memo request
        ls_borident-objtype = 'BUS2096'.
      WHEN 'C'.                               "Orders
        ls_borident-objtype = 'BUS2032'.
      WHEN OTHERS.
        CLEAR ls_borident-objtype.
    ENDCASE.

    IF NOT ls_borident-objtype IS INITIAL.
      CONCATENATE 'ZGOSVA01' sy-uname sy-datum sy-uzeit   INTO ls_borident-objkey.
      EXPORT ls_borident-objkey TO MEMORY ID 'ZGOSVA01' .

      CREATE OBJECT lr_gos_manager
        EXPORTING
          is_object        = ls_borident
          ip_start_direct  = ' '
          ip_no_commit     = 'X'
        EXCEPTIONS
          object_invalid   = 1
          callback_invalid = 2
          OTHERS           = 3.
      lv_flag = 'X'.
    ENDIF.

  ENDIF.

[Here with the help of static variable (LV_FLAG), we are making sure that this piece of code will be triggered only once in an entire session of sales order creation. There was another challenge regarding object key. At this moment sales order number was not generated in SAP, so we have created a default unique key concatenating a text ' ZGOSVA01' and username and date and time. We will use it later in our code]

 

2.5 Step 5: We have to attach that document to newly created sales order. So code needs to be added in user exit MV45AFZZ inside form USEREXIT_SAVE_DOCUMENT.



The Syntax is:

  DATA: lt_services    TYPE tgos_sels,    "Services table type
ls_source      TYPE sibflporb,    "Source
ls_target      TYPE sibflporb,    "Target
ls_borident    TYPE borident,
lv_temp_object TYPE borident-objkey.

CLEAR: ls_source,
ls_target,
ls_borident-objkey.

CASE vbak-vbtyp.
WHEN 'K'.                               "Credit memo request
ls_source-typeid = 'BUS2094'.
ls_target-typeid = 'BUS2094'.
WHEN 'L'.                               "Debit memo request
ls_source-typeid = 'BUS2096'.
ls_target-typeid = 'BUS2096'.
WHEN 'C'.                               "Orders
ls_source-typeid = 'BUS2032'.
ls_target-typeid = 'BUS2032'.
WHEN OTHERS.
CLEAR: ls_source,
ls_target.
ENDCASE.

IF NOT ls_source-typeid IS INITIAL.
IMPORT ls_borident-objkey FROM MEMORY ID 'ZGOSVA01' .
lv_temp_object = ls_borident-objkey.

* Source
ls_source-instid =  lv_temp_object.
ls_source-catid  = 'BO'.

* Target
ls_target-instid = vbak-vbeln.
ls_target-catid  = 'BO'.

*  Move file from Temporary Object to Sales Order Object
cl_gos_service_tools=>move_linked_objects(
is_source             = ls_source
is_target             = ls_target
it_service_selection  = lt_services
).
ENDIF.

[Here we are moving attached file from temporary object to sales order object]

 

3.   Steps to create attachments for Sales Order:


 

Following are the step by step instructions to create any attachment for sales order:

3.1 Step 1:



3.2 Step 2: Click on the GOS toolbar. Different options will be displayed.



3.3 Step 3: Click on ‘Create-> Create attachment’ option.

3.4 Step 4: A pop-up window will be opened to find a file or attachment as shown below.  Select the file and click on open.



3.5 Step 5: A success message will be displayed in the task bar.



3.6 Step 6: If we open sales order in display/change mode, you can see the document in Service: Attachment list tab.



 

4.0   Appendix


 

This document would be useful for different groups of business users while creation of new credit-memo or debit memo request (Sales Order) in SAP system. In the above way, using ‘Generic Object services toolbar’ or ‘GOS toolbar’ different files can be attached.
6 Comments