cancel
Showing results for 
Search instead for 
Did you mean: 

Table access in SAPScript

Former Member
0 Kudos

I apologize if this is elementary but this is my first time working with SAPScript. I am trying to modify a SAPScript form. I am attempting to add our Material Document Number to printed checks form. This number is stored in the AWKEY field (BKPF-AWKEY). Do I need to declare the table BKPF anywhere in the form before I use it? To display this number I added &BKPF-AWKEY& but it is the first time table BKPF is being used in the form. Any help is appreciated. I do not have a test case to test my change yet so I was hoping if anybody on here could tell me if it would/should work or not.

Thanks,

Aaron

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Aaron,

All the code work u have to do it in Print program not in Sapscript.

in Sapscript u have to give only the variable name.

fetch ur field value into a itab along with other values to represent.

pass the field BKPF-AWKEY to the main window to write_form F.M. from ur print program from itab or standard table.

and u can represent the field in sapscript like &BKPF-AWKEY& or &ITAB-AWKEY&

Regards

CNU

Former Member
0 Kudos

Srinu and Sudheer, thanks for your reply but I am still confused.

Is there an example that you can point me to? BKPF is not being used at all but REGUP is. The program is RFFOUS_C but I can't figure out what i need to add where to pass BKPF-AWKEY. Is there any way that you can point me towards the right direction? I am VERY NEW to SAP/ABAP/SAPScript. If it would help I can post the code for the report RFFOUS_C.

Thanks,

Aaron

Former Member
0 Kudos

hi Aaron,

R u using standard program or Zprogram?

R u using Standard Sapscript or zsapscript?

If u r using z_program then in include RFFORI01 it is printing checks there u can try to add ur fields.

if u r using z_sapscript then use perform command to print new values from the subroutine u write in other program.

Regards

CNU

Former Member
0 Kudos

We are using a standard program (RFFOUS_C) but a zsapscript. I was looking in RFFORI01 but I am not sure where to add my fields. I was looking at the code for quite a while and could not come up with anything.

I apologize if I seem unintelligent but this is very new to me. This is the first time I have seen or worked with any SAPScript.

Thanks,

Aaron

Message was edited by:

Aaron Shover

Former Member
0 Kudos

It looks like the program RFFOUS_C is Selecting data into BKPF.

I'm not positive, but you should be able to just add &BKPF-AWKEY& to your Sapscript form.

Give it a try and let us know.

Former Member
0 Kudos

In RFFOUS_C program in include RFFORI99..

SELECT SINGLE * FROM BKPF WHERE BUKRS EQ REGUP-BUKRS

AND BELNR EQ REGUP-BELNR

AND GJAHR EQ REGUP-GJAHR.

this statement selects the BKPF-AWKEY also from BKPF.

try to print a BKPF-AWKEY value in zsapscript.

for testing purpose..

in Main window in Sapscript

/: ULINE (70)

  • &BKPF-AWKEY&

/: ULINE (70)

so u know the sapscript retrieving bkpf-awkey value or not.

If sapscript cant retrieve this data then u need to write a subroutine using other values to get BKPF-AWKEY.

Regards

CNU

Former Member
0 Kudos

Thanks for that reply! I was thinking that I needed to put a select like that in the program somewhere but I wasn't sure where. I am waiting to receive a test case so that I can test the zsapscript. Does it matter where in the include (RFFORI99) I put the select?

Thanks again for the reply.

Aaron

Former Member
0 Kudos

That is what I am hoping but I don't even have a test case yet to test that. I am waiting for somebody to get me a test case so I can see if that works.

Thanks,

Aaron

Former Member
0 Kudos

Hi Aaron,

In Include RFFORI99, we cant add custom code we dont have permission to modify the standard program.

If the above program in previous reply doesn't work then we can add a subroutine in sapscript and can implement in other zprogram like.

/: PERFORM TEST_ROUTINE IN PROGRAM ZTEST

/: USING &REGUP-FIELD&

/: CHANGING &MY_FIELD&

/: ENDPERFORM.

ZTEST is a zprogram where u can implement subroutine TEST_ROUTINE.

here we can write select statement:

EX: select single awkwy from bkpf into lv_awkey where field = &REGUP-FIELD&.

Let us know once you get the test case, so we can move forward.

Regards

CNU

Former Member
0 Kudos

I will let you know once I get the test case. I can't thank you enough for all of your help. I am attending the SAP training course BC460 (SAPScript) but that isn't available until April 16th. I wish it was available sooner.

Thanks again,

Aaron

Former Member
0 Kudos

Ok, I have a test case in hand and I tried a quick test and I found out that simply putting &BKPF-AWKEY& does not work. I assume I need to put a select statement in the program (or an include as you pointed out) but I am not sure where.

Thanks,

Aaron

Former Member
0 Kudos

HI Aaron,

I think u have to use Subroutine to get the BKPF-AWKEY value in ur sapscript.

In sapscript...

*************************************************************

/: PERFORM TEST_ROUTINE IN PROGRAM ZTEST

/: USING ®UP-BUKRS&

/: USING ®UP-BELNR&

/: USING ®UP-GJAHR&

/: CHANGING &MY_BKPF_AWKEY&

/: ENDPERFORM.

  • &MY_BKPF_AWKEY&

**************************************************************

Create a report ZTEST ( or ur name specific must match with perform program name in sapscript).

*****************************************************************

TABLES: BKPF.

DATA: L_BUKRS LIKE REGUP-BUKRS,

L_BELNR LIKE REGUP-BELNR,

L_GJAHR LIKE REGUP-GJAHR,

L_AWKEY LIKE BKPF-AWKEY.

FORM TEST_ROUTINE TABLES IN_PAR STRUCTURE

ITSCY

OUT_PAR STRUCTURE ITCSY.

change to

FORM TEST_ROUTINE TABLES IN_PAR STRUCTURE

ITCSY

OUT_PAR STRUCTURE ITCSY.

READ TABLE IN_PAR WITH KEY 'REGUP-BUKRS'.

IF SY-SUBRC = 0.

L_BUKRS = IN_PAR-VALUE.

ENDIF.

READ TABLE IN_PAR WITH KEY 'REGUP-BELNR'.

IF SY-SUBRC = 0.

L_BELNR = IN_PAR-VALUE.

ENDIF.

READ TABLE IN_PAR WITH KEY 'REGUP-GJAHR'.

IF SY-SUBRC = 0.

L_GJAHR = IN_PAR-VALUE.

ENDIF.

SELECT SINGLE AWKEY FROM BKPF INTO L_AWKEY WHERE BUKRS = L_BUKRS BELNR = L_BELNR GJAHR = L_GJAHR.

READ TABLE OUT_PAR WITH KEY 'MY_BKPF_AWKEY'.

IF SY-SUBRC = 0.

MY_BKPF_AWKEY = L_AWKEY.

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDFORM.

*********************************************************************

i am assuming that table REGUP values are passing to the form. If not code is same just change the table name and variables for relation with BKPF table.

hope it solves the problem...

let me know if u need some more information

Regards

CNU

Former Member
0 Kudos

Thank you for that wonderful reply! I am on my way to a meeting for the rest of the day but I will try this later tonight or tomorrow morning. Thanks again for all of your help! I just can't wait until I get more experience under my belt so I can help others.

Thanks again,

Aaron

Former Member
0 Kudos

Hello Srinu,

Where in the SAPScript do I put

/: PERFORM TEST_ROUTINE IN PROGRAM ZTEST

/: USING &REGUP-BUKRS&

/: USING &REGUP-BELNR&

/: USING &REGUP-GJAHR&

/: CHANGING &MY_BKPF_AWKEY&

/: ENDPERFORM.

Thanks for your help!

Aaron

Former Member
0 Kudos

Hi Aaron,

In SAPscript layout editor... to the window it consists... i assume Main Window.

Righ click on main window... EDIT Text.

Goto Edit --> Change Editor.

there u can write this code

If u have any Text Elements then u must know under which text element u have to display this BKPF-AWKEY. under the texr element provide the code.

*************************************************************

/: PERFORM TEST_ROUTINE IN PROGRAM ZTEST

/: USING &REGUP-BUKRS&

/: USING &REGUP-BELNR&

/: USING &REGUP-GJAHR&

/: CHANGING &MY_BKPF_AWKEY&

/: ENDPERFORM.

/: ULINE(75)

  • &MY_BKPF_AWKEY&

/: ULINE(75)

**************************************************************

i am giving ULINE(75) just to know that variable is executing ...( testing purpose)

Regards

CNU

Former Member
0 Kudos

Hello Sirnu,

I am beginning to try out the code you posted but I ran into a slight problem. In the ztest program there is a line:

FORM TEST_ROUTINE TABLES IN_PAR STRUCTURE ITSCY OUT_PAR STRUCTURE ITCSY.

What is ITCSY? It gives me an error saying that ITSCY is unknown.

Thanks for all of your help!

Aaron

Former Member
0 Kudos

hi Aaron,

ITCSY is a structure name which has Program symbol field name and it value.

like using statement in perform...

Using &REGUP-BUKRS& is a program symbol field name and its value.

pls make sure the the structure name is ITCSY....

Regards

CNU

Former Member
0 Kudos

Hi Srinu,

The structure is ITCSY. Why do you think it can't see the structure in the ztest program?

Thanks,

Aaron

Former Member
0 Kudos

HI Aaron,

in my above code by mistake i wrote it as itscy... pls change to ITCSY.. make sure the Subroutine name and ZTEST program name is same as u given in Sapscript form.

I am not sure what is the problem that it cant see the structure in ur program

FORM TEST_ROUTINE TABLES IN_PAR STRUCTURE ITCSY OUT_PAR STRUCTURE ITCSY.

READ TABLE IN_PAR WITH KEY 'REGUP-BUKRS'.

IF SY-SUBRC = 0.

L_BUKRS = IN_PAR-VALUE.

ENDIF.

READ TABLE IN_PAR WITH KEY 'REGUP-BELNR'.

IF SY-SUBRC = 0.

L_BELNR = IN_PAR-VALUE.

ENDIF.

READ TABLE IN_PAR WITH KEY 'REGUP-GJAHR'.

IF SY-SUBRC = 0.

L_GJAHR = IN_PAR-VALUE.

ENDIF.

SELECT SINGLE AWKEY FROM BKPF INTO L_AWKEY WHERE BUKRS = L_BUKRS BELNR = L_BELNR GJAHR = L_GJAHR.

READ TABLE OUT_PAR WITH KEY 'MY_BKPF_AWKEY'.

IF SY-SUBRC = 0.

MY_BKPF_AWKEY = L_AWKEY.

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDFORM.

for further help u can double clcik on any field or table name .....

and on commands place the cursor and press F1 for help.

Regards

CNU

Former Member
0 Kudos

Hi Srinu,

The link below is a screenshot of my zSAPScript. I have included the code you provided me with and I created a program called ZTest. However, nothing is happening. I'm not sure if I have the code in the wrong spot or if I messed the code up in some way. If you wouldn't mind looking at it and letting me know what I did wrong I would appreciate it. Thanks again for all of your help!

http://img81.imageshack.us/img81/6758/20070112140616gv8.jpg

Regards,

Aaron

Former Member
0 Kudos

hi Aaron,

I think the place of the perform is wrong.... it comes under different text element.

U need to place where the REGUP table items r displaying.

525

--


line items--

/: PROTECT

  • &REGUP-BELNR* &REGUP-

-


HERE PLACE THE PERFORM----


/: PERFORM TEST_ROUTINE IN PROGRAM ZTEST

/: USING &REGUP-BUKRS&

/: USING &REGUP-BELNR&

/: USING &REGUP-GJAHR&

/: CHANGING &MY_BKPF_AWKEY&

/: ENDPERFORM.

/: ULINE(70)

  • &MY_BKPF_AWKEY&

/: ULINE(70)

/: ENDPROTECT

if doesn't work try to place in other text element... in ur code in form...

If it also doesn't work then try to print the

&REGUP-BUKRS&

&REGUP-BELNR&

&REGUP-GJAHR&

these values so we might know that these values r actually fetching from print program.

Regards

CNU

Former Member
0 Kudos

Hi Srinu and Sudheer,

I tried putting a break point in the ZTest program and it never reaches the program. Do I need the /: and the * before each command?

Regards,

Aaron Shover

Former Member
0 Kudos

Hello Srinu,

I have found, in the main program (RFFOUS_C) where it calls the form (Write_form). I also discovered that the main program does indeed reference the table I need (BKPF). How do I pass the value to the form in the write_form command? I can't find much documentation on write_form. As always, any help is more than appreciated!

Regards,

Aaron

Former Member
0 Kudos

HI Aaron,

GIve me ur email id... so i send the SAPScript document which is useful for u to learn in detail.

and also some screen shots of the perform statement in script command editor.

Regards

CNU

I sent it to ur hotmail...

Message was edited by:

srinu k

Message was edited by:

srinu k

Former Member
0 Kudos

Hi Srinu, Thank you for the email. I am looking at it now.

Regards,

Aaron

Message was edited by:

Aaron Shover

Message was edited by:

Aaron Shover

Former Member
0 Kudos

Thank you so much Srinu (and everybody else that helped). After Srinu showed me where to edit my SAPScript I got it working. Now comes the task of getting it formatted on the form. Thanks again for all of your help!

Regards,

Aaron

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Aaron,

Your Perform is

/: PERFORM TEST_ROUTINE IN PROGRAM ZTEST.
/: USING &REGUP-BUKRS&
/: USING &REGUP-BELNR&
/: USING &REGUP-GJAHR& 
/: CHANGING &MY_BKPF_AWKEY&
/: ENDPERFORM

In the ZTEST Program.

FORM TEST_ROUTINE TABLES IN_PAR STRUCTURE ITCSY OUT_PAR STRUCTURE ITCSY.

DATA: L_BUKRS type BUKRS.

L_BELNR type BELNR.

L_GJAHR type ZJAHR.

L_AWKEY type AWKEY.

READ TABLE IN_PAR WITH KEY 'REGUP-BUKRS'.

IF SY-SUBRC = 0.

L_BUKRS = IN_PAR-VALUE.

ENDIF.

READ TABLE IN_PAR WITH KEY 'REGUP-BELNR'.

IF SY-SUBRC = 0.

L_BELNR = IN_PAR-VALUE.

ENDIF.

READ TABLE IN_PAR WITH KEY 'REGUP-GJAHR'.

IF SY-SUBRC = 0.

L_GJAHR = IN_PAR-VALUE.

ENDIF.

SELECT SINGLE AWKEY FROM BKPF INTO L_AWKEY WHERE BUKRS = L_BUKRS BELNR = L_BELNR GJAHR = L_GJAHR.

READ TABLE OUT_PAR WITH KEY 'MY_BKPF_AWKEY'.

IF SY-SUBRC = 0.

MY_BKPF_AWKEY = L_AWKEY.

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDFORM.

This Should work, just put a Break point in the ZTEST Program, and see the Values of L_BUKRS L_BELNR L_GJAHR .

Regards

Sudheer

Former Member
0 Kudos

Hi,

The from values will be stored in Structure while running the SAPSCRIPT, so i think the field &BKPF-AWKEY& won't give you the correct one, if it is giving then there is no need to declare the TABLES statment anywhere, if you are not gettting the correct one with this field &BKPF-AWKEY&, then you need to write the External perform and get the value then use it.