cancel
Showing results for 
Search instead for 
Did you mean: 

SapScrit SQL query

Former Member
0 Kudos

Does any know how can I select data from the window´s text element?, I need to consult something from a SAP table, and I seems to be not possible.

Any Idea?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Can you please be more specific? I really don't know what you are asking. More info, please.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Rich,

Thanks for your help!!

I have a form in tcode se71, when I enter and go to the 'main' window I can edit the text elements, I mean to write text into the form (for example name, adress etc), I need to make a SQL query (select * from ....) there in order to write in the letter specific data that I dont have in memory during that moment. To be more specific I need to write in the form the field LFB5-BUSAB giving the LIFNR field to the query.

Thanks

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I would suggest making this field available in your print program. You must do your data retrieval in the ABAP code. In your print program, define your field, fill it with data, then you can use it in the SAPscript.

&LFB5-BUSAB&

You could also do a PERFORM in the sapscript to retreive the data, but the previous is much easier.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi,

The problem that i have is that i´m not using my own print program, i´m using a standard instead. So how do you use it with PERFORM? if I cant use a sql query?

Tnanks for your help again.

Gabriel

Former Member
0 Kudos

Hi Gabriel,

You can write a perform irrespective of the print program. Here is the example..

Retrieving data without modifying the original called program

*

  • Retrieving data without modifying the original called program

*

  • Put this script code in your sapscripts

  • /: PERFORM GET_BARCODE IN PROGRAM ZSCRIPTPERFORM

  • /: USING &PAGE&

  • /: USING &NEXTPAGE&

  • /: CHANGING &BARCODE&

  • /: ENDPERFORM

  • / &BARCODE&

*

*

REPORT ZSCRIPTPERFORM.

FORM GET_BARCODE TABLES IN_PAR STRUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

DATA: PAGNUM LIKE SY-TABIX, "page number

NEXTPAGE LIKE SY-TABIX. "number of next page

READ TABLE IN_PAR WITH KEY 'PAGE'.

CHECK SY-SUBRC = 0.

PAGNUM = IN_PAR-VALUE.

READ TABLE IN_PAR WITH KEY 'NEXTPAGE'.

CHECK SY-SUBRC = 0.

NEXTPAGE = IN_PAR-VALUE.

READ TABLE OUT_PAR WITH KEY 'BARCODE'.

CHECK SY-SUBRC = 0.

IF PAGNUM = 1.

OUT_PAR-VALUE = '|'. "First page

ELSE.

OUT_PAR-VALUE = '||'. "Next page

ENDIF.

IF NEXTPAGE = 0.

OUT_PAR-VALUE+2 = 'L'. "Flag: last page

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDFORM.

Hope this helps.

Former Member
0 Kudos

Gabriel,

You can do this without changing the original driver program.

You will still need a custom program, but this custom program will only contain subroutines to be called from within the sapscript form.

Create a custom program and then follow as below

Here is an example of how your subroutine should be:


* Considering that the custom program name is ZZZZZZZZ
FORM GET_DESC
   TABLES IN_TAB  STRUCTURE ITCSY
          OUT_TAB STRUCTURE ITCSY.

  DATA: L_MATNR TYPE MARA-MATNR,
        L_MAKTX TYPE MAKT-MAKTX.

  READ TABLE IN_TAB INDEX 1 .
  IF SY-SUBRC EQ 0.
    L_MATNR      = IN_TAB-VALUE.

    SELECT SINGLE MAKTX INTO L_MAKTX FROM MAKT
      WHERE MATNR EQ L_MATNR
      AND   SPRAS EQ SY-LANGU.
    IF SY-SUBRC EQ 0.
      OUT_TAB-VALUE = L_MAKTX.
      MODIFY OUT_TAB INDEX 1 TRANSPORTING VALUE.
    ENDIF.
  ENDIF.

ENDFORM.

* In your Sapscript form, you would have the 
* following statement

/:  PERFORM GET_DESC IN PROGRAM ZZZZZZZZ
/:  USING &MARA-MATNR&
/:  CHANGING &MAKT-MAKTX&
/:  ENDPERFORM

For further help, use the SAP help link below and select

"Calling ABAP Subroutines: PERFORM" in the left pane.

<u>http://help.sap.com/saphelp_erp2004/helpdata/EN/d1/802fd3454211d189710000e8322d00/frameset.htm</u>

Hope this helps.

Cheers,

-Ramesh

Former Member
0 Kudos

Hi Gabriel,

Reward and close the post if its helpful to you.

Answers (0)