cancel
Showing results for 
Search instead for 
Did you mean: 

How many different ways of dynamically displaying a text?

Former Member
0 Kudos

Hi folks,

I've been assigned to work on the following:

The SapScript form on which I am supposed to work, currently has hard coded text with some variables such as name of the customer, order number, special info, etc, coming from the driver program.

I must change the form such that depending on the company code there would be a different logo, different header, different footer, different body of text, some with extra paragraphs added, removed, etc... The general layout of the form remains the same throughout.

So in other words, this SapScript form must be dynamic enough to be able to accommodate all these demand.

The customer would ultimately like to update a table or tables and the text in the SapScript form is changed accordingly and without any programming effort.

Different copies of the same form is not an option because company codes come and go and change rather frequently.

So, how would you go about it?

Your help is greatly appreciated.

Edited by: Goharjou ardavan on Jun 17, 2008 8:11 PM

Accepted Solutions (1)

Accepted Solutions (1)

valter_oliveira
Active Contributor
0 Kudos

Hello.

To keep one script (good option) I would add extra text elements for hardcoded texts, and use variables as much as I can for text elements that are equal in structure. This way, all the control of the dynamic data would be done in driver program, instead of the script.

For example, in LOGO window, you have an include statement, right? The name of the graphic that contains the logo could be a variable, that varyies with the company code.

script (LOGO window)

/E LOGO

/: INCLUDE &LOGO_VAR& ...

driver program


IF company_code EQ 'CODE1'.
  LOGO_VAR = 'GRAPHIC_LOGO1'.
ELSE.
  LOGO_VAR = 'GRAPHIC_LOGO2'.
ENDIF.

Differently, in harcoded text, I would have different text elements, like:

script (HEADER window)

/E HEADER1

AS This is the header for company 1

/E HEADER2

AS This is the header for company 2

driver program


IF company_code EQ 'CODE1'.
  CALL FUNCTION 'WRITE_FORM' 
  EXPORTING
       window = 'HEADER'  
       element = 'HEADER1'.
ELSE.
  CALL FUNCTION 'WRITE_FORM' 
  EXPORTING
    window = 'HEADER'
    element = 'HEADER2'
ENDIF.

Regards,

Valter Oliveira.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Do the following

-> Create a table with the following fields like Company code logo Name,header, footer, body text now maintain the values in the table for eack company code .

-> In the driver program write as follows.

Select * from zlogo(which you defined)

into wa_zlogo

where bukrs = your bukrs.

Now in the form include them with the include text.

/: Include &wa_zlogo-logo& object text id st LANGUAGE EN

/: include &wa_logo-header& object text id st LANGUAGE EN paragraph p1

/: include &wa_logo-footer&................

/: include &wa_logo-body& ...............

Thanks,

NN.

Former Member
0 Kudos

Hi,

The only solution is, need to add the conditions in the script.

According to the company code or other conditions, we need to add the text or any.

There is no any concept called dynamic, need to add the code with respect to the business requirement.

Bye

Former Member
0 Kudos

Hi,

It's a very good practice to have only one SAP script. However ideally you do not have to touch the pgm if say a new company is added.

This can be achieved as below:

DATA: w_VAR1(30),

w_i(1).

*

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

form = 'ZKIL'.

*

w_i = '1'.

Concatenate 'AMEND_HEADING' w_i into w_var1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = w_VAR1

window = 'MAIN'.

CALL FUNCTION 'CLOSE_FORM'

EXPORTING

device = 'PRINTER'

form = 'ZKIL'.

In the above pgm there are 2 text elements defined in SAP script ZKIL viz. AMEND_HEADING1 & AMEND_HEADING2. In the driver pgm get the company code & put in w_i which should be defined as CHAR 4. so that all your text element name should be derived by Concatenating 'Text element name' & w_i & then use that variable in FM WRITE_FORM so that even if tomorrow a new company is added only a corresponding text elements need to be added in SAP SCRIPT & no changes are required in the pgm.

I hope this helps,

Regards

Raju Chitale