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.
Showing results for 
Search instead for 
Did you mean: 

Format field output in SAPScript

0 Kudos


I want to mask all but the last 4 digits of a bank account that is output to SAPscript. The bank account number is populated through &REGUH-ZBNKN&. The bank account number length can vary, so it is not possible to set a constant offset like &REGUH-ZBNKN+4&. The SAPscripty itself is called by a standard SAP program therefore do not want to make any chnages in teh SAP program itself.

Can you advise if there is any way within the SAPscript itself to ensure only the last 4 digits contained in &REGUH-ZBNKN& are output? If this has to be done by the PERFORM statement, can I design a new own Z program (independent of the SAP calling program) and dynamically call that from within the SAPscript to output the last 4 digits?

Can you advise the general approcah please?

Thanks for any ideas



Former Member
0 Kudos

hi Michael,

Try &REGUH-ZBNKN(4)&  hopefully it will work out your requirement.

0 Kudos

Unfortunatley Sai this will only pick the 1st 4 digits of the field, not sure if there is anyway to pick teh last 4 digits of the field. Note the field can have contents which vary in length, so saying &REGUH-ZBNKN+6& etc is not possible

Former Member
0 Kudos

You can always call an external perform from inside the SAPScript.


Former Member
0 Kudos

Perform statement needs to be used which will call subroutine of your custom program.

Here is SAP Help and wiki article with example.

Former Member
0 Kudos

Hi Michael,

Create a Sub Routine Pool Program with a form in SE38. Call the same in your SAPScript Window where you want to do play with values. The structure out_tab and in_tab have values.

Eg :-


form F140_LOGO TABLES     p_in_tab  STRUCTURE itcsy

                          p_out_tab STRUCTURE itcsy.

*-- <logic>