06-08-2006 6:41 AM
06-08-2006 6: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
06-08-2006 6: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.
06-08-2006 6:47 AM
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
06-08-2006 6: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
06-08-2006 6: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.
06-08-2006 6: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
06-08-2006 7:09 AM
hi vijay,
my question is it is possible in script only not in report program
06-08-2006 7:12 AM
hi kiran,
we cannot write a select statement in a SAPSCRIPT.
in smartforms though, this can be done.
06-08-2006 7:17 AM
Hi Kiran,
It is not possible to write select statement in Scripts.
Regards,
SP.
06-08-2006 7:25 AM
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
06-08-2006 6: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