cancel
Showing results for 
Search instead for 
Did you mean: 

how to declare variable in the scipt

Former Member
0 Kudos

data is coming from standard program .

rf140-stida key entry date.

bsik-bldat posting date

i want to display difference between rf140-stida and bsik-bldat in scipt form it will give number of days.

how can i declare variables for this.

how to write code in my form.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

U need to create a routine to calculate the difference:

/: DEFINE &DELTA& = SPACE

/: PERFORM <FORM NAME> IN PROGRAM <PROGRAN NAME>

/: USING &RF140-STIDA&

/: USING &BSIK-BLDAT&

/: CHANGING &DELTA&

  • &DELTA&

The routine has to be defined in your Z-PROGRAM and to have these interface:

FORM <FORM NAME>  TABLES IN_TAB_EM     STRUCTURE ITCSY
                                                   OUT_TAB_EM STRUCTURE ITCSY.

  DATA: DELTA TYPE I.

  DATA: DATE1 LIKE SY-DATUM,
             DATE2 LIKE SY-DATUM.

* ---> Rembember the date has the ouput format, so it has to be converted in the 
* input format

  READ TABLE  IN_TAB_EM WITH KEY NAME = 'RF140-STIDA'.
  IF SY-SUBRC = 0.
     DATE1(4)     = IN_TAB_EM-VALUE+6(4).
     DATE1+4(2) = IN_TAB_EM-VALUE+3(2).
     DATE1+6(2) = IN_TAB_EM-VALUE(2).  
  ENDIF.

  READ TABLE  IN_TAB_EM WITH KEY NAME = 'BSIK-BLDAT'.
  IF SY-SUBRC = 0.
     DATE2(4)     = IN_TAB_EM-VALUE+6(4).
     DATE2+4(2) = IN_TAB_EM-VALUE+3(2).
     DATE2+6(2) = IN_TAB_EM-VALUE(2).  
  ENDIF.

  DELTA = DATE1 - DATE2.

  READ TABLE  OUT_TAB_EM WITH KEY NAME = 'DELTA'.
  IF SY-SUBRC = 0.
     WRITE DELTA TO OUT_TAB_EM-VALUE.
     MODIFY OUT_TAB_EM INDEX SY-TABIX.
  ENDIF.


ENDFORM.

Max

Answers (2)

Answers (2)

Former Member
0 Kudos

Your variable is declared using command DEFINE, your calculation will need to be done in an ABAP subroutine and called using the PERFORM command (different from the regular ABAP command).

Online help has plenty on both of these commands.

<a href="http://help.sap.com/saphelp_47x200/helpdata/en/d2/cb3d07455611d189710000e8322d00/frameset.htm">SAP help</a>

Section 'SAPscript control commands'

Regards,

Nick

Former Member
0 Kudos

Hi,

DEFINE is the keyword to declare the variables in the SAPSCRIPT.

/: DEFINE &symbol_name&

To get the diffrence, then you need to write the PERFORM in the SAPSCRIPT, and in the for do the diefference and pass the value to the script and print it

Regards

Sudheer