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

select stmt in script

hi,

where we can write select stmt in sap-script?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Jun 08, 2006 at 05:49 AM

    check the example

    script code...

    /:   PERFORM GET_UNITS IN PROGRAM ZGET_MASTER
    /:   USING &EKPO-MATNR&
    /:   CHANGING &V_UMREZ&
    /:   CHANGING &V_LAENG&
    /:   CHANGING &V_BREIT&
    /:   CHANGING &V_HOEHE&
    /:   CHANGING &V_MEABM&
    /:   CHANGING &V_BRGEW&
    /:   CHANGING &V_GEWEI&
    /:   CHANGING &V_EAN11&
    /:   CHANGING &V_MATNR&
    /:   ENDPERFORM

    Logic to be written in Z Program

    REPORT  zget_master         .        
                .
    FORM get_units TABLES in_tab STRUCTURE itcsy out_tab STRUCTURE itcsy.
      CLEAR v_matnr.
      READ TABLE in_tab INDEX 1.
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
        EXPORTING
          input  = in_tab-value
        IMPORTING
          output = v_matnr.
      SELECT SINGLE matnr                 "Material number
                    umrez                 "Numerator for conversion
                    ean11                 "International article number
                    laeng                 "Length
                    breit                 "Width
                    hoehe                 "Height
                    meabm                 "Unit dimension for (L,W,H)
                    brgew                 "Gross weight
                    gewei                 "Weight unit
                    FROM marm
                    INTO
      (v_matnr,v_umrez,v_ean11,v_laeng,v_breit,v_hoehe,v_meabm,v_brgew,
       v_gewei)
                    WHERE matnr = v_matnr
                    AND  meinh  = c_meinh2.
      IF sy-subrc = 0.
        READ TABLE out_tab INDEX 1.
        MOVE v_umrez TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
        READ TABLE out_tab INDEX 2.
        MOVE v_laeng TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
        READ TABLE out_tab INDEX 3.
        MOVE v_breit TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
        READ TABLE out_tab INDEX 4.
        MOVE v_hoehe TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
        READ TABLE out_tab INDEX 5.
        MOVE v_meabm TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
        READ TABLE out_tab INDEX 6.
        MOVE v_brgew TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
        READ TABLE out_tab INDEX 7.
        MOVE v_gewei TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
        READ TABLE out_tab INDEX 8.
        MOVE v_ean11 TO out_tab-value.
        CONDENSE out_tab-value.
        MODIFY out_tab INDEX sy-tabix.
      ENDIF.
      READ TABLE out_tab INDEX 9.
      MOVE v_matnr TO out_tab-value.
      CONDENSE out_tab-value.
      MODIFY out_tab INDEX sy-tabix.
    ENDFORM.                    "get_units

    Regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2006 at 05:46 AM

    Hi kiran

    You write the select query in the code before you call the FM for the script. You would place the necessary data from the internal table in Script. Loop FM 'WRITE_FORM' and print the data from the internal table into the Script.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 08, 2006 at 05:48 AM

    Hi Kiran,

    if you want it in the script layout directly it is not possible . but indirect way is there. using perform.

    in side the perform you can use select statement.

    regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2006 at 05:49 AM

    In the Driver program you will be writing the select statement. Before using the FMs open form... u will have select the data from the database and u'll display it with the help of the 5 FMs.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 08, 2006 at 05:54 AM

    you can't directly put the query in script but you can call a function. and put your query in function.

    like this.

    /: PERFORM INC_PAGE IN PROGRAM program_name

    /: ENDPERFORM

    and define a function like this.

    FORM inc_page tables in_tab structure itcsy out_tab structure itcsy.

    SELECT * FROM tab_name INTO TABLE itab.

    ENDFORM.

    Regards,

    Wasim Ahmed

    Add a comment
    10|10000 characters needed characters exceeded

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.