Sapscript Example Calling ABAP Program

Tips by: Prem endren

Sapscript coding :-
*************************
/:   PERFORM F_58_GROSS IN PROGRAM ZFI_PMT_ADV
/:   USING &REGUP-DMBTR&
/:   USING &REGUP-DMBT1&
/:   USING &REGUP-DMBT2&
/:   USING &REGUP-SKFBT&
/:   CHANGING &W_DMBTR&
/:   CHANGING &W_DMBT1&
/:   CHANGING &W_DMBT2&
/:   ENDPERFORM
T1   &REGUP-BELNR&,,&REGUP-XBLNR&,,&REGUP-BLDAT& &W_DMBTR(16T)

Note:- here we passed USING parameters & got CHANGING parameters

Abap coding :-
********************
Program name :-  ZFI_PMT_ADV

FORM f_58_gross TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy.

  DATA : dmbtr LIKE regup-dmbtr,
         dmbt1 LIKE regup-dmbt1,
         dmbt2 LIKE regup-dmbt2,
         skfbt LIKE regup-skfbt,
         rdmbtr LIKE regup-dmbtr,
         rdmbt1 LIKE regup-dmbt1,
         rdmbt2 LIKE regup-dmbt2,
         temp(16) TYPE c,
         temp1 TYPE p.

  READ TABLE in_par WITH KEY 'REGUP-DMBTR'.
  CHECK sy-subrc = 0.
  temp = in_par-value.
  CONDENSE temp.
  REPLACE ALL OCCURRENCES OF ',' IN temp WITH ''.
  temp1 = temp.
  dmbtr = temp1.
  READ TABLE in_par WITH KEY 'REGUP-DMBT1'.
  CHECK sy-subrc = 0.
  temp = in_par-value.
  CONDENSE temp.
  REPLACE ALL OCCURRENCES OF ',' IN temp WITH ''.
  temp1 = temp.
  MOVE temp1 TO dmbt1.
  READ TABLE in_par WITH KEY 'REGUP-DMBT2'.
  CHECK sy-subrc = 0.
  temp = in_par-value.
  CONDENSE temp.
  REPLACE ALL OCCURRENCES OF ',' IN temp WITH ''.
  temp1 = temp.
  MOVE temp1 TO dmbt2.
  READ TABLE in_par WITH KEY 'REGUP-SKFBT'.
  CHECK sy-subrc = 0.
  temp = in_par-value.
  CONDENSE temp.
  REPLACE ALL OCCURRENCES OF ',' IN temp WITH ''.
  temp1 = temp.
  MOVE temp1 TO skfbt.

  rdmbtr = dmbt1 + dmbt2.
  rdmbt1 = rdmbtr - dmbtr.
  rdmbt2 = 0.

  IF dmbt1 EQ 0.
    IF skfbt LT dmbtr.
      rdmbtr = dmbtr.
      rdmbt1 = 0.
    ELSE.
      rdmbtr = skfbt.
      rdmbt1 = skfbt - dmbtr.
    ENDIF.
  ENDIF.

  REFRESH out_par.
  temp = rdmbtr.
  out_par-name = 'W_DMBTR'.
  out_par-value = temp.
  APPEND out_par.
  temp = rdmbt1.
  out_par-name = 'W_DMBT1'.
  out_par-value = temp.
  APPEND out_par.
  temp = rdmbt2.
  out_par-name = 'W_DMBT2'.
  out_par-value = temp.
  APPEND out_par.

ENDFORM.

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.