Skip to Content
author's profile photo Former Member
Former Member

Initialization in SAP Query

Hi,

I have created a SAP query with MSEG as one of the tables. I am using MATNR of MSEG.

I need to initialize the values of material before query is executed. Filter is based on one of the Characteristic which can not be done using variants. I could see there is an option to write code in dirrerent events of Report e.g. Initialization, Start-Of-Selection.

I selected the required materials in an internal tables in INITIALIZATION event. How can i pass these materials as default in Select-Option of MSEG-MATNR.

Any pointers will be highly appreciated.

Regards

Ashish

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 10, 2009 at 09:41 AM

    In the infoset, you will find the selection-screen field NAMES in the SELECTIONS tab, at left of the CODE tab. Use the NAME of the field you want to default in the code of the INITIALIZATION event. Example : if your field has name XX and its type is selection criteria ("SelCrit"), if you want to default it to values AAA or BBB, then add this code:

    XX-sign = 'I'.
    XX-option = 'EQ'.
    XX-low = 'AAA'.
    APPEND XX.
    XX-low = 'BBB'.
    APPEND XX.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2009 at 09:48 AM

    Hi,

    If you are working in T.Code :SQVI, then it is not possible.

    If you are working with SQ01, SQ02., You can do this in SQ02.

    Through Menu Option there, use GOTO --> Code -->

    Here you can create some code and intitilize the value for material.

    Regds,

    ANil

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      Try the code below:

      *---Authorization for Company code entered by the users.
      *---This code will restrict users to see data for company
      *---codes which they are not authorized to.
      
      *---Select all the company codes based upon selection entered by the
      *---user
      
       SELECT bukrs
         FROM t001
         INTO TABLE li_bukrs
        WHERE bukrs IN z_bukrs.
      
      
       IF sy-subrc EQ 0.
      
      *---Clear Screen variable for Company code
         CLEAR z_bukrs.
         REFRESH z_bukrs.
      
      *---Filter and prepare Select options for Company code table to be
      *---passed to query. Table will only have values of company codes he is
      *---authorized to for display.
      
         LOOP AT li_bukrs INTO lwa_bukrs.
      
           AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
                             ID 'BUKRS' FIELD lwa_bukrs
                             ID 'ACTVT' FIELD '03'.
      
           IF sy-subrc = 0.
             z_bukrs-sign = 'I'.
             z_bukrs-option = 'EQ'.
             z_bukrs-low = lwa_bukrs.
             z_bukrs-high = space.
             APPEND z_bukrs.
           ELSE.
             lv_flag = 'X'.
           ENDIF.
      
         ENDLOOP.
      *---Give warning message to the user in case he is not authorized to see
      *---data for all the company codes that he has entered.
      
         IF lv_flag = 'X'.
           MESSAGE ID 'ZF_MSS_FNG' TYPE 'W' NUMBER '015'.
         ENDIF.
      
       ENDIF.

      Just make sure that Z_BUKRS field is available in selection tab.

      Also, declare below mentioned variables in INITIALIZATION.

      DATA: li_bukrs TYPE TABLE OF bukrs,
             lwa_bukrs TYPE bukrs,
             lv_flag TYPE c.

      KR Jaideep,

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.