Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing Sap Script ????

Former Member
0 Kudos

I am customizing predefined form MEDRUCK and making the 3 forms ZMEDRUCK1,ZMEDRUCK2,ZMEDRUCK3 each form i am adding different fields which are not available in the predefined form.

I am using predefined print program SAPFM06P i dont want to change the predefined program, where should i write the logic for the added fields.

Thanking in advance.,

Ravi

6 REPLIES 6

Former Member
0 Kudos

Hi Ravi,

CALL a PERFORM - ENDFORM from sap script and define a subroutine pool to write your own logic.

Check the links

http://www.sapdevelopment.co.uk/sapscript/sapscript_executeabap.htm

The code will be something similar.

REPORT YLSD999A.
DATA  W_LENGTH TYPE I.
*   GENERAL PURPOSE SUBROUTINES FOR CALLING FROM SAPSCRIPTS
*-----------------------------------------------------------------------
*----------------------------------------------------------------------
FORM DISPLAY_POUND TABLES IN_TAB STRUCTURE ITCSY
                          OUT_TAB STRUCTURE ITCSY.
  DATA: COUNT TYPE P VALUE 16.
  DATA: W_VALUE(17) TYPE C.        "defined as 7 chars to remove pence
  DATA: W_CHAR TYPE C.
  DATA: W_DUMMY TYPE C.
  DATA: W_CURR(3) TYPE C.
*    Get first  parameter in input table.
  READ TABLE IN_TAB INDEX 1.
  WRITE IN_TAB-VALUE TO W_VALUE .
* get second parameter in input table
  READ TABLE IN_TAB INDEX 2.
  MOVE IN_TAB-VALUE TO W_CURR.
  IF W_CURR = 'GBP'.
    W_CURR = '£'.
  ENDIF.
  W_LENGTH = STRLEN( W_CURR ).
*    look for first space starting at right.
  WHILE COUNT > -1.
    W_CHAR = W_VALUE+COUNT(1).
*  W_CHAR = IN_TAB-VALUE+COUNT(1).
    IF W_CHAR = ' '.
      COUNT = COUNT - W_LENGTH + 1.
      W_VALUE+COUNT(W_LENGTH) = W_CURR.
      COUNT = -1.
    ELSE.
*     W_VALUE+COUNT(1) = W_CHAR.
      COUNT = COUNT - 1.
    ENDIF.
  ENDWHILE.
* read only parameter in output table
  READ TABLE OUT_TAB INDEX 1.
  OUT_TAB-VALUE = W_VALUE.
  MODIFY OUT_TAB INDEX SY-TABIX.
ENDFORM.


Cheers

VJ

PERFORM ... IN PROGRAM .... USING.. CHANGING ..

ENDPERFORM

To call ABAP subroutines from within a form we use the

PERFORM... IN PROGRAM ... statement , the advantage of

using it is that the print program is not required to cahnge and we

can get the new data from the subroutine which is placed in a Z

report . To pass and get the values from th subroutine the

parameters are passed which are of type structure ITCSY.

e.g. /:PERFORM get_date IN PROGRAM zreport

/:USING &SALESORDER&

/:CHANGING &S_DATE&

/:ENDPERFORM

The date &S_DATE& ....

The ABAP Code would be

REPORT zreport.

TABLES ztab.

FORM get_date TABLES in_tab STRUCTURE ITCSY out_tab

STRUCTURE ITCSY .

READ TABLE in_tab INDEX 1.

SELECT some_date FROM ztab WHERE salesorder = in_tab-value.

IF sy-subrc EQ 0.

READ TABLE out-tab INDEX 1.

MOVE ztab-somedate TO out_tab-value

MODIFY out_tab INDEX 1.

ENDIF.

ENDFORM.

In the above code USING is used to pass the value to the

subroutine while changing is used to recieve the value from th

subroutine ,for further paramters we can use either USING or

CHANGING .

In the subroutine the type of paramter is always an internal table of

type ITCSY irrespective of the value passed.The VALUE field

of the internal table is used to fill and recieve the values .

Message was edited by: Vijayendra Rao

0 Kudos

Hi VJ,

Thanks,

where we call this subroutinue in the print program, since iam using this program for 3 customized forms how can the program detect when to execute which form.

Ravi

0 Kudos

Hi Ravi,

The subrotuine is called from the SAP SCRIPT. You have modified the MEDRUCK into ZMEDRUCK rite? Add a PERFORM and ENDFORM statement in the ZMEDRUCK and the subroutine will be called automatically when the script is called.

Here is the flow

1). SAPFM06P will call the ZMEDRUCK based on your customization of the output types.

2). ZMEDRUCK will call the Subrotuine

Hope this answer ur queries.

Cheers

VJ

Former Member
0 Kudos

HI

GOOD

I DONT THINK WITHOUT CHANING THE STANDARD PROGRAM YOU CAN ADD THE EXTRA FIELD IN THE SAP SCRIPT FROM ,BECAUSE ANYWAY YOU R GOING TO PASS THE VALUE TO THOSE FIELD USING YOUR DRIVER PROGRAM.

THANKS

MRUTYUN

Former Member
0 Kudos

Hi Ravi,

if u have to call these 3 forms under some diff conditions, then theres no way u can do it without changing the print program, because the program decides which form to call...u can definitely make the setting in NACE for the form, but it allows only one form at a time..as ur requirement is to call the forms conditionally, i suggest u to copy the print program n make the required settings... that would be more appropriate/..

Regards

Former Member
0 Kudos

Hi VJ,

Please can you forward the documentation of notes on SAPScripts and Smartforms.

Thanks in advance.

Ravi