cancel
Showing results for 
Search instead for 
Did you mean: 

Can we change the value of a variable in the driver program from sapscript?

aris_hidalgo
Contributor
0 Kudos

Hello Experts,

I am currently developing a form wherein I need to change the value of a variable defined in the standard

driver program through the sapscript form. Unfortunately, I cannot customize this standard program since this is used by many other

subsidiaries. So, is there anyway that I can change a variable defined in the driver program via sapscript?

I tried to use a PERFORM to change its value but it is not working.

I hope you can help me guys. Thank you and take care!

Accepted Solutions (1)

Accepted Solutions (1)

former_member585060
Active Contributor
0 Kudos

Hi,

You can do it using PERFORM statement, can you paste how you wrote your PERFORM statement and its corresponding Subroutine

Regards

Bala Krishna

aris_hidalgo
Contributor
0 Kudos

Hi Guys,

Here is what I did. I am trying to change the value of BKPF-GJAHR from '2007' to '2008'. So in my sapscript it goes something like this:

SAPSCRIPT:


/:     perform change_gjahr in program zchange_gjahr
/:     using &BKPF-GJAHR&
/:     changing &BKPF-GJAHR&
/:     endperform

ZCHANGE_GJAHR:


FORM change_gjahr TABLES im_input STRUCTURE itcsy
                                            ex_output STRUCTURE itcsy.

field-symbols: <fs_input> type itcsy,
                     <fs_output> type itcsy.

constants: lcc_gjahr type char10 value 'BKPF-GJAHR'.

read table im_input assigning <fs_input> with key name = lcc_gjahr.
if sy-subrc = 0.
if <fs_input>-value = '2007'.
read table ex_output assigning <fs_output> with key name = lcc_gjahr.
if sy-subrc = 0.
<fs_output>-value = '2008'.
endif.
endif.
endform.

former_member181995
Active Contributor
0 Kudos

Your Form Routine Code is Wrong.You need to change(modify) internal table ex_output,because this itab is carrying your changes to script in changing &BKPF-GJAHR&

Change would be on line

ex_output-value = '2008'.

aris_hidalgo
Contributor
0 Kudos

Hi,

If you check again my code I am using field-symbol <fs_output> where I pass the value of '2008' to field VALUE.

former_member181995
Active Contributor
0 Kudos

Okay,

just check once by giving Break-point at last executabe statement, does here ex_output-value = '2007'.Because finally your values are passing script via ex_output.

aris_hidalgo
Contributor
0 Kudos

Hi Amit,

I debugged it and it is passing the value '2008' for BKPF-GJAHR in my routine but when it goes back to the form it reverts back to '2007'.

former_member585060
Active Contributor
0 Kudos

Hi,

Do as below, define a variable in SAPScript using DEFINE statement for GJHAR, and remove the output field BKPF-GJHAR in SAPScript value, give the defined variable in place of that (GJHAR).

do the following modification in your coding both in FORM and soubroutine, hope this will solve

/: DEFINE &GJHAR& = '0000'

/: perform change_gjahr in program zchange_gjahr

/: using &BKPF-GJAHR&

/: changing &GJAHR&

/: endperform

FORM change_gjahr TABLES im_input STRUCTURE itcsy

ex_output STRUCTURE itcsy.

data : wa_gjhar TYPE bkpf-gjhar.

READ TABLE im_input INDEX 1.

wa_gjhar = im_input-value.

IF wa_gjhar = '2007'.

wa_gjhar = '2008'.

ENDIF.

READ TABLE ex_output INDEX 1.

MOVE wa_gjhar TO ex_output-value.

MODIFY ex_output INDEX sy-tabix.

endform.

Regards

Bala Krishna

aris_hidalgo
Contributor
0 Kudos

Hi.

As my topic suggests, I need to change the value of a given variable declared in the standard driver program through sapscript.

former_member585060
Active Contributor
0 Kudos

Hi,

If you use the same variable BKPF-GJHAR, its value will be always same in form, as it is coming from the Driver program.

In the above subroutine program it changes the value according to condition, if conditions fails it retains the original value.

Regards

Bala Krishna

Edited by: Bala Krishna on Dec 19, 2008 11:46 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

SAP SCRIPT:

/: PERFORM GET_ATTNDEE_INFO IN PROGRAM ZHR_TRNG

/: USING &PPVAR-EOBJD&

/: CHANGING &ATTND&

/: ENDPERFORM

Executable Prog.:

REPORT ZHR_TRNG.

FORM GET_ATTNDEE_INFO TABLES IN_PAR STRUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

DATA : LOC_CODE(8),

WF_NAME LIKE PA0001-ENAME, "----Location Code

WF_SOBID LIKE HRP1001-SOBID. "----Business Event Code

DATA: BEGIN OF ITAB_ECODE OCCURS 0,

ECODE(8),

END OF ITAB_ECODE.

DATA: NAME1 TYPE STRING.

READ TABLE IN_PAR INDEX 1.

LOC_CODE = IN_PAR-VALUE.

SELECT SOBID FROM HRP1001 INTO WF_SOBID

WHERE OBJID = LOC_CODE AND OTYPE ='E' AND PLVAR = '01' AND SCLAS = 'P'.

APPEND WF_SOBID TO ITAB_ECODE .

ENDSELECT.

IF SY-SUBRC = 0.

LOOP AT ITAB_ECODE.

SELECT SINGLE ENAME FROM PA0001 INTO WF_NAME

WHERE PERNR = ITAB_ECODE-ECODE ." AND ENDDA >= '31.12.9999' .

CONCATENATE 'Mr ' WF_NAME ',' NAME1 INTO NAME1.

IF SY-SUBRC = 0 .

OUT_PAR-NAME = 'ATTND'.

OUT_PAR-VALUE = NAME1.

APPEND OUT_PAR.

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM. "GET_USR_INFO