Application Development and Automation 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: 
Read only

SAP Scripts customizing

Former Member
0 Likes
1,137

Hello Experts,

I am new to SAP Scripts and trying to learn more to customize the standard SAP Scripts. Could some one please verify the below logic and please let me know if I am on the right track. Any inputs are highly appreciated.

I have a requirement to modify MEDRUCK SAP Script. 

Requirement: I need to include 4 extra fields that needs to be displayed in the RFQ form.

RFQ is Request For Quotation and the standard form using now is MEDRUCK. So I need to modify the MEDRUCK SAP Script form now.

 

I need to display TABLE1-X1, TABLE2-X2, TABLE2-X3, TABLE2-X4 in the MEDRUCK form in addition to the current data that is displayed.

 

TABLE1-X1 should be retrieved from TABLE1 WHERE TABLE1-X5 = EKPO-X5.

TABLE2-X2 should be retrieved from TABLE2 WHERE TABLE2-X6 = EKPO-MATNR.

TABLE2-X3 should be retrieved from TABLE2 WHERE TABLE2-X6 = EKPO-MATNR.

TABLE2-X4 should be retrieved from TABLE2 WHERE TABLE2-X6 = EKPO-MATNR.

So, I will create a subroutine pool program and have the logic in it. Please let me know if the below procedure is correct.

 

In the SAP Script Main window, I will include below logic on where the new fields needs to be displayed.

/: PERFORM GET_ITEM_DATA IN PROGRAM Z_POOL

/:          USING &EKPO-X5&

/:          USING &EKPO-MATNR&

/:          CHANGING &X1&

/:          CHANGING &X2&

/:          CHANGING &X3&

/:          CHANGING &X4&

/: ENDPERFORM.

/: IF &X1& NE ' '

/  ,,,,&'X1 data: 'X1&

/: ENDIF

/: IF &X2& EQ 'DRB' OR 'MFG' OR 'MFN' OR 'MSB' OR 'MSP'

/  ,&'X2 data: 'X2&,&'X3 data: 'X3&,&'X4 data: 'X4&

/:ENDIF

Now creating the sub-routine pool Z_POOL which has below code.

FORM GET_ITEM_DATA TABLES Z_USING STRUCTURE ITCSY

                                Z_CHANGING STRUCTURE ITCSY.

DATA: L_X5 TYPE EKPO-X5,

      L_X6 TYPE EKPO-MATNR.

READ TABLE Z_USING WITH KEY NAME = 'EKPO-X5'.

IF SY-SUBRC EQ 0.

   MOVE Z_USING-VALUE TO L_X5.

ENDIF.

IF NOT L_X5 IS INITIAL.

SELECT SINGLE X1 FROM TABLE1 INTO Z_CHANGING-VALUE

WHERE TABLE1-X5 = L_X5.

IF SY-SUBRC EQ 0.

   MOVE 'X1' TO Z_CHANGING-NAME.

   APPEND Z_CHANGING.

ENDIF.

ENDIF.

CLEAR Z_CHANGING.

READ TABLE Z_USING WITH KEY NAME = 'EKPO-MATNR'.

IF SY-SUBRC EQ 0.

   MOVE Z_USING-VALUE TO L_X6.

ENDIF.

IF NOT L_X6 IS INITIAL.

   SELECT SINGLE X2 FROM TABLE2 INTO Z_CHANGING-VALUE

   WHERE TABLE2-X6 = L_X6.

   IF SY-SUBRC EQ 0.

      MOVE 'X2' TO Z_CHANGING-NAME.

      APPEND Z_CHANGING.

   ENDIF.

ENDIF.

CLEAR Z_CHANGING.

IF NOT L_X6 IS INITIAL.

   SELECT SINGLE X3 FROM TABLE2 INTO Z_CHANGING-VALUE

   WHERE TABLE2-X6 = L_X6.

   IF SY-SUBRC EQ 0.

      MOVE 'X3' TO Z_CHANGING-NAME.

      APPEND Z_CHANGING.

   ENDIF.

ENDIF.

CLEAR Z_CHANGING.

IF NOT L_X6 IS INITIAL.

   SELECT SINGLE X4 FROM TABLE2 INTO Z_CHANGING-VALUE

   WHERE TABLE2-X6 = L_X6.

   IF SY-SUBRC EQ 0.

      MOVE 'X4' TO Z_CHANGING-NAME.

      APPEND Z_CHANGING.

   ENDIF.

ENDIF.

ENDFORM.

Thanks!

9 REPLIES 9
Read only

Former Member
0 Likes
1,096

Hello again,

Can someone please have a look and validate?

Your help is much appreciated.

Thanks!

Sandy

Read only

0 Likes
1,096

Hi

First of all in SAP script before Perform you ahve to use DEFINE statement to define these variables X1,X@ etc using DEFINE &X1& = ' '. etc.

Secondly you dont have to append to ZCHANGING you have modify as ZCHANGIN table will already have changing variable NAME. Only you need to modify VALUE

Nabheet

Read only

0 Likes
1,096

Hi Nabheet,

Thanks for taking time to go through my post and respond.

Could you please explain more on your statement "Secondly you don't have to append to zchanging you have modify as table"?

Appreciate if you could point out on where I went wrong.

Thanks!

Read only

0 Likes
1,096

If you are able to execute your program. Put a break point in subroutine pool and check at the beginning the contents of Z_CHANGING it must already be filled with changing field names only value must be blank. So instead of APPEND Z_CHANGING.

you should have modify zchanging from  Z_CHANGING where fieldname = 'X1' etc.

Please put a sreen shot of debugger with break point at beginning of this sub routine and put a screen shot showing contents of ZCHANGING

Read only

0 Likes
1,096

Hi Nabheet,

I did not place the logic in the subroutine yet. I am still verifying on the code before I go ahead and create. Per your reply I understand that the Changing name will already be present in Z_CHANGING-NAME before entering the module pool itself. We need to move only the Z_CHANGING-VALUE.

So, instead having

IF SY-SUBRC EQ 0.

      MOVE 'X1' TO Z_CHANGING-NAME.

      APPEND Z_CHANGING.

   ENDIF.

We need to have,

IF SY-SUBRC EQ 0.

      modify z_changing from  Z_CHANGING where z_changing-name = 'X1'

   ENDIF.

Please let me know if my understanding is correct. Also please let me know if all the other logic correct.

Thanks so much!

Read only

0 Likes
1,096

All looks ok:) start the coding...:)

Read only

0 Likes
1,096

Thanks Nabheet

I will start with the coding. Also, after the changes are done, how will the configuration be done? In the NACE transaction, we just change the sap script name and the print program remains the same. Do we need to specify the subroutine pool?

Thanks!

Read only

0 Likes
1,096

Nopes

Read only

0 Likes
1,096

Okay. Thanks!