Application Development and Automation 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: 
Read only

Select query in SAP SCRIPT

Former Member
0 Likes
2,878

Dear Experts,

In printing of MB23n , I need to print STR_SUPPL1 and STR_SUPPL2 from ARDC table. I already have ADDRNUMBER.

We are using SAP SCRIPT.

Please guide me how to insert the following query in SAP SCRIPT.

tables: lfa1, adrc.

data: begin of it_test occurs 0 ,

str_suppl1 like adrc-str_suppl1,

str_suppl2 like adrc-str_suppl2,

end of it_test.

select str_suppl1 str_suppl2 into corresponding fields of table it_test from adrc addrnumber = lfa1-adrnr.

Please hekp me to solve the issue.

Thanks in advance.

Regards

Ankur

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,703

Hi Ankur

May be you can write a short program and include all the desired code/functionality into it and then call the same in the required Page Window of your SAP Script.

Hope this helps.

Harsh

8 REPLIES 8
Read only

Former Member
0 Likes
1,703

Hi Ankur,

You will need to write this select query in your print program and use these variables in the script.

In the scripts you cannot fetch the data.

If your print program is standard, then you will need to create subroutine in another custome program and call that in the script.

Please let me know if you need more help on this.

Thanks,

Archana

Read only

0 Likes
1,703

hello archana

thanks for quick response.

can you please guide me the steps to write a subroutine and call the same in SAP Script.

I am new to ABAP, please help.

Regards

Ankur

Read only

Former Member
0 Likes
1,704

Hi Ankur

May be you can write a short program and include all the desired code/functionality into it and then call the same in the required Page Window of your SAP Script.

Hope this helps.

Harsh

Read only

0 Likes
1,703

hello harish,

thanks for the response.

can you please guide me the steps to create an include and call the same in my script.

please help.

regards

Ankur

Read only

0 Likes
1,703

Hi Ankur,

Please go through below link. It has provided good explanation of creation subroutines in scripts.

[http://wiki.sdn.sap.com/wiki/display/profile/ExternalSubroutinesinSAPScript]

Let me know if you don't understand anything.

Thanks,

Archana

Read only

0 Likes
1,703

Ankur

You'll be creating this program, just as you do other programs in tcode se38.

Then Write in the Window Editor:

PERFORM Var_1 IN PROGRAM ZTEST USING (some variables as per your requirement)

ENDPERFORM.

Refer to the [link|http://wiki.sdn.sap.com/wiki/display/profile/ExternalSubroutinesinSAPScript] for more details.

Hope this helps.

Harsh

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,703

- Create a subroutine pool program (or add to an existing one) - create a FORM/ENDFOM

- From a SAPscript form, you can call those Abap Forms (read [SUBROUTINES AND THEIR USE IN SAPSCRIPT |http://wiki.sdn.sap.com/wiki/display/ABAP/SUBROUTINESANDTHEIRUSEIN+SAPSCRIPT])

Regards,

Raymond

Read only

Former Member
0 Likes
1,703

Hi,

In Script - Page Window -


 	PERFORM <form name> IN PROGRAM <Program Name>
 	USING &VBDKR-VBELN_VL&
 	USING &VBDKR-VBELN_VAUF&
 	CHANGING &ADDR_LINE1&
 	CHANGING &ADDR_LINE2&
 	CHANGING &ADDR_LINE3&
 	CHANGING &ADDR_LINE4&
 	CHANGING &ADDR_LINE5&
 	ENDPERFORM
                     &ADDr_line1&&ADDR_LINE3& &ADDr_line2&
 	&ADDR_LINE4&
 	PROTECT
 	&ADDR_LINE5&
 	ENDPROTECT

In SE38 - Create Prog as Subroutine pool --> Write a Form with same name


SELECT SINGLE adrnr INTO twlad-adrnr FROM twlad WHERE werks = lips-werks AND
                                                          lgort = lips-lgort.

    IF sy-subrc = 0.
      CALL FUNCTION 'ADDRESS_INTO_PRINTFORM'
        EXPORTING
          address_type            = '1'
          address_number          = twlad-adrnr
        IMPORTING
          address_printform_table = lt_address.