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: 

Assigning a Value to a Text Symbol: DEFINE

Former Member
0 Kudos

Hi all,

I am printing some text in the form. The text is in the database table and is retrieved. say the field name is fld06 in the table ztfin. Previously it is code as &zfin-fld06& in the form edotir. Now my requiremnet is to dispay some other text where ever I have to print ztfin-fld06. I have used the define statement in this way :

/: DEFINE &ztfin-fld06& = 'Data Fattura'

But when I look at the output the text is not replaced nor it is realised while I am debugging. Can anyone tellme where I am going wrong ?

Regards,

Varun.

Message was edited by: varun sonu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi

chk this out

<b>DEFINE: Value assignment to text symbols

Text symbols receive their value through an explicit assignment. This assignment can be made interactively in the editor via the menu options Include &#61614;&#61472;&#61614;&#61472;Symbols &#61614;&#61472;&#61614;&#61472;Text. This lists all the text symbols of a text module, as well as those of the allocated layout set.

The contents defined in this way are lost if the transaction is exited. To continue printing the text module, you would have to enter the symbol values again.The DEFINE command allows you to anchor this value assignment firmly in the text, to also have it available when you next call up the text. Furthermore, you can allocate another value to a text symbol in

the course of the text.

Syntax:

/: DEFINE &symbolname& = ‘value’

Example:

/: DEFINE &re& = ‘Your correspondence of 3/17/94’

Example:

/: DEFINE &symbol1& = ‘xxxxxxx’

/: DEFINE &symbol2& = ‘yyy&symbol1&’

/: DEFINE &symbol1& = ‘zzzzzzz’

Result: &symbol2& &#61614;&#61472;yyyzzzzzzz

The assigned value may have a maximum of 60 characters. It can also contain further symbols. When a symbol is defined using the control command DEFINE, symbols which occur in the value are not immediately replaced by their value. They are only replaced when the target symbol is output. If the operator := is used in the DEFINE statement, all symbols which occur in the value which is to be assigned are immediately replaced by their current values. The resulting character string is only then assigned to the target symbol when all occurring symbols have been replaced. The length of the value is limited to 80 characters. The target symbol must be a text symbol, as at present.

Syntax:

/: DEFINE &symbolname& := ‘value’</b>

<i>u can also write a perform...endperform to change the value of a field to ur required text.</i>

6 REPLIES 6

LucianoBentiveg
Active Contributor
0 Kudos

Try defining an auxiliar variable and work with these. Example:

/: DEFINE &aux_var& = ''

Later

/: &aux_var& = &ztfin-fld06&

Or

/: &aux_var& = 'Data Fattura'

0 Kudos

Hi,

Can anyonee xplain me how the define works in sapscript. This doesn't work for me. Can anyone explain me where I am going wrong.

Any way thanks for your concern peluka.

Regards,

Varun.

Message was edited by: varun sonu

Former Member
0 Kudos

hi

chk this out

<b>DEFINE: Value assignment to text symbols

Text symbols receive their value through an explicit assignment. This assignment can be made interactively in the editor via the menu options Include &#61614;&#61472;&#61614;&#61472;Symbols &#61614;&#61472;&#61614;&#61472;Text. This lists all the text symbols of a text module, as well as those of the allocated layout set.

The contents defined in this way are lost if the transaction is exited. To continue printing the text module, you would have to enter the symbol values again.The DEFINE command allows you to anchor this value assignment firmly in the text, to also have it available when you next call up the text. Furthermore, you can allocate another value to a text symbol in

the course of the text.

Syntax:

/: DEFINE &symbolname& = ‘value’

Example:

/: DEFINE &re& = ‘Your correspondence of 3/17/94’

Example:

/: DEFINE &symbol1& = ‘xxxxxxx’

/: DEFINE &symbol2& = ‘yyy&symbol1&’

/: DEFINE &symbol1& = ‘zzzzzzz’

Result: &symbol2& &#61614;&#61472;yyyzzzzzzz

The assigned value may have a maximum of 60 characters. It can also contain further symbols. When a symbol is defined using the control command DEFINE, symbols which occur in the value are not immediately replaced by their value. They are only replaced when the target symbol is output. If the operator := is used in the DEFINE statement, all symbols which occur in the value which is to be assigned are immediately replaced by their current values. The resulting character string is only then assigned to the target symbol when all occurring symbols have been replaced. The length of the value is limited to 80 characters. The target symbol must be a text symbol, as at present.

Syntax:

/: DEFINE &symbolname& := ‘value’</b>

<i>u can also write a perform...endperform to change the value of a field to ur required text.</i>

Former Member
0 Kudos

When ever you want to assing value to variable in SAP Script, always define with DEFINE statement.

Like

/: DEFINE &TEXT& = 'Data Fattura'

/: DEFINE &TEXT& = &ZTFIN-FLD06&

After that suppose you want to clear the value then use

/: DEFINE &ZTFIN-FLD06& = ' '

and at the end print &TEXT& variable where you want to print.

Please award points if it helps you.

Regards

Aman

0 Kudos

Hi,

Thank you all friends for your constant support.

Thanks and REgards,

Varun.

Former Member
0 Kudos

hi

U CAN ALSO USE THIS CODE

/: PERFORM CHANGE_NAME FROM PROGRAM ZCHANGE

CHANGING ztfin-fld06

REPORT ZCHANGE.

FORM CHANGE_NAME TABLES ITAB STRUCTURE ITCSY

OTAB STRUCTURE ITCSY.

DATA: FLD06 TYPE ztfin-fld06 ,

TEXT TYPE STRING.

*READ TABLE ITAB WITH KEY NAME = 'ztfin-fld06 '.

*FLD06 = ztfin-fld06.

TEXT = 'DATA FATTURA'

READ TABLE OTAB WITH KEY NAME = 'ztfin-fld06 '.

OTAB-VALUE = TEXT.

APPEND OTAB.

ENDFORM.