‎2008 Mar 29 6:16 AM
‎2008 Mar 29 6:21 AM
Hi,
You can do that by writing perform in SAP SCRIPT window and write the subrouting in one report.
For Eg:
See the sample code in script
/: IF &PAGE& EQ 1.
/: DEFINE &STREET&
/: DEFINE &STR_SUPPL1&
/: DEFINE &TEMP&
/: PERFORM GET_DATA_ADRC IN PROGRAM Z_RFFOUS_C
/: USING &LFA1-ADRNR&
/: CHANGING &STREET&
/: CHANGING &STR_SUPPL1&
/: CHANGING &TEMP&
/: ENDPERFORM.
/: ENDIFand in the program Z_RFFOUS_C.
incorporate your subroutine code.
*---------------------------------------------------------------------*
* FORM GET_DATA_ADRC *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> IT_USING *
* --> IT_CHANGING *
*---------------------------------------------------------------------*
FORM GET_DATA_ADRC TABLES IT_USING STRUCTURE ITCSY
IT_CHANGING STRUCTURE ITCSY.
DATA : ADRNR LIKE LFA1-ADRNR.
DATA : L_STREET LIKE ADRC-STREET,
L_STR_SUPPL1 LIKE ADRC-STR_SUPPL1,
L_STR_SUPPL2 LIKE ADRC-STR_SUPPL2,
L_STR_SUPPL3 LIKE ADRC-STR_SUPPL3,
L_LOCAT LIKE ADRC-LOCATION.
DATA : TEMP(220).
READ TABLE IT_USING INDEX 1.
MOVE IT_USING-VALUE TO ADRNR.
UNPACK ADRNR TO ADRNR.
SELECT SINGLE STREET
STR_SUPPL1
STR_SUPPL2
STR_SUPPL3
LOCATION
FROM ADRC
INTO (L_STREET,
L_STR_SUPPL1,
L_STR_SUPPL2,
L_STR_SUPPL3,
L_LOCAT)
WHERE
ADDRNUMBER = ADRNR.
READ TABLE IT_CHANGING INDEX 1.
IT_CHANGING-VALUE = L_STREET.
MODIFY IT_CHANGING INDEX 1.
*
READ TABLE IT_CHANGING INDEX 2.
IT_CHANGING-VALUE = L_STR_SUPPL1.
MODIFY IT_CHANGING INDEX 2.
*
* read table it_changing index 3.
* it_changing-value = l_str_suppl2.
* modify it_changing index 3.
*
* read table it_changing index 4.
* it_changing-value = l_str_suppl3.
* modify it_changing index 4.
*
* read table it_changing index 5.
* it_changing-value = l_locat.
* modify it_changing index 5.
* concatenate l_str_suppl2 l_str_suppl3 l_locat into temp.
CONCATENATE L_STR_SUPPL2
','
L_STR_SUPPL3
','
L_LOCAT INTO TEMP.
WHILE SY-SUBRC = 0.
REPLACE ',' WITH ' ' INTO TEMP.
ENDWHILE.
READ TABLE IT_CHANGING INDEX 3.
IT_CHANGING-VALUE = TEMP.
MODIFY IT_CHANGING INDEX 3.
ENDFORM.revert me back if you face any issues.
Reward points if my answer is helpful.
~Lakshmiraj~
Edited by: LAKSHMIRAJ on Mar 29, 2008 7:22 AM
‎2008 Mar 29 6:19 AM
Hi,
Refer the following links:
http://help.sap.com/saphelp_46c/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm
http://www.sap-basis-abap.com/abap/how-to-call-a-subroutine-form-sapscripts.htm
Regards,
Kiran Sure
‎2008 Mar 29 6:21 AM
Hi,
You can do that by writing perform in SAP SCRIPT window and write the subrouting in one report.
For Eg:
See the sample code in script
/: IF &PAGE& EQ 1.
/: DEFINE &STREET&
/: DEFINE &STR_SUPPL1&
/: DEFINE &TEMP&
/: PERFORM GET_DATA_ADRC IN PROGRAM Z_RFFOUS_C
/: USING &LFA1-ADRNR&
/: CHANGING &STREET&
/: CHANGING &STR_SUPPL1&
/: CHANGING &TEMP&
/: ENDPERFORM.
/: ENDIFand in the program Z_RFFOUS_C.
incorporate your subroutine code.
*---------------------------------------------------------------------*
* FORM GET_DATA_ADRC *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> IT_USING *
* --> IT_CHANGING *
*---------------------------------------------------------------------*
FORM GET_DATA_ADRC TABLES IT_USING STRUCTURE ITCSY
IT_CHANGING STRUCTURE ITCSY.
DATA : ADRNR LIKE LFA1-ADRNR.
DATA : L_STREET LIKE ADRC-STREET,
L_STR_SUPPL1 LIKE ADRC-STR_SUPPL1,
L_STR_SUPPL2 LIKE ADRC-STR_SUPPL2,
L_STR_SUPPL3 LIKE ADRC-STR_SUPPL3,
L_LOCAT LIKE ADRC-LOCATION.
DATA : TEMP(220).
READ TABLE IT_USING INDEX 1.
MOVE IT_USING-VALUE TO ADRNR.
UNPACK ADRNR TO ADRNR.
SELECT SINGLE STREET
STR_SUPPL1
STR_SUPPL2
STR_SUPPL3
LOCATION
FROM ADRC
INTO (L_STREET,
L_STR_SUPPL1,
L_STR_SUPPL2,
L_STR_SUPPL3,
L_LOCAT)
WHERE
ADDRNUMBER = ADRNR.
READ TABLE IT_CHANGING INDEX 1.
IT_CHANGING-VALUE = L_STREET.
MODIFY IT_CHANGING INDEX 1.
*
READ TABLE IT_CHANGING INDEX 2.
IT_CHANGING-VALUE = L_STR_SUPPL1.
MODIFY IT_CHANGING INDEX 2.
*
* read table it_changing index 3.
* it_changing-value = l_str_suppl2.
* modify it_changing index 3.
*
* read table it_changing index 4.
* it_changing-value = l_str_suppl3.
* modify it_changing index 4.
*
* read table it_changing index 5.
* it_changing-value = l_locat.
* modify it_changing index 5.
* concatenate l_str_suppl2 l_str_suppl3 l_locat into temp.
CONCATENATE L_STR_SUPPL2
','
L_STR_SUPPL3
','
L_LOCAT INTO TEMP.
WHILE SY-SUBRC = 0.
REPLACE ',' WITH ' ' INTO TEMP.
ENDWHILE.
READ TABLE IT_CHANGING INDEX 3.
IT_CHANGING-VALUE = TEMP.
MODIFY IT_CHANGING INDEX 3.
ENDFORM.revert me back if you face any issues.
Reward points if my answer is helpful.
~Lakshmiraj~
Edited by: LAKSHMIRAJ on Mar 29, 2008 7:22 AM
‎2008 Mar 30 11:07 AM
Hi,
The Form :
/:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
/:USING &EKKO-EBELN&
/:CHANGING &CDECENT&
/:ENDPERFORM
The report :
REPORT zkrpmm_perform_z1medruck .
DATA : BEGIN OF it_input_table OCCURS 10.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_input_table.
déclaration de la table output_table contenant les
variables exportées
DATA : BEGIN OF it_output_table OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_output_table.
DATA : w_ebeln LIKE ekko-ebeln,
w_vbeln LIKE vbak-vbeln,
w_zcdffa LIKE vbak-zcdffa.
*----
*
FORM CDE_CENT
*
*----
*
FORM cde_cent TABLES input output.
it_input_table[] = input[].
it_output_table[] = output[].
READ TABLE it_input_table INDEX 1.
MOVE it_input_table-value TO w_ebeln.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_ebeln
IMPORTING
output = w_ebeln.
SELECT SINGLE zcdffa FROM ekko
INTO w_zcdffa
WHERE ebeln = w_ebeln.
it_output_table-name = 'CDECENT'.
MOVE w_zcdffa TO it_output_table-value.
MODIFY it_output_table INDEX 1.
output[] = it_output_table[].
ENDFORM.
Reward if helpful...
Sravani.