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: 

select stmt in script

Former Member
0 Kudos

hi,

where we can write select stmt in sap-script?

1 ACCEPTED SOLUTION

former_member188685
Active Contributor

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

10 REPLIES 10

Former Member
0 Kudos

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.

0 Kudos

Hi Kiran,

Use the Command PERFORM .... ENDPERFORM from the script and write a subrotuine to write ur abap code.

http://www.sapdevelopment.co.uk/sapscript/sapscript_executeabap.htm

Cheers

VJ

Message was edited by: Vijayendra Rao

former_member188685
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

former_member188685
Active Contributor

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

0 Kudos

hi vijay,

my question is it is possible in script only not in report program

0 Kudos

hi kiran,

we cannot write a select statement in a SAPSCRIPT.

in smartforms though, this can be done.

0 Kudos

Hi Kiran,

It is not possible to write select statement in Scripts.

Regards,

SP.

0 Kudos

Hi Kiran,

it is not possible directly in script layout, but you can do it as mentioned in my above post to use select.

Regards

vijay

dani_mn
Active Contributor
0 Kudos

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