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: 

How to use if.. else.. statement in Call Function

Former Member
0 Kudos

Hi All,

May i know how to use if else statement in Call Function? I need to create another language for textline1 = 'PLEASE SELECT REASON FOR CHANGE'(006) in Norwegian.

How to create a new variable that would hold the different texts for different language?

IF NOT i_spopli[] IS INITIAL.

DO.

CALL FUNCTION 'POPUP_TO_DECIDE_LIST'

EXPORTING

mark_flag = ' '

mark_max = 1

start_col = 80

start_row = 5

textline1 = 'PLEASE SELECT REASON FOR CHANGE'(006)

titel = 'REASON FOR CHANGE'(002)

IMPORTING

answer = l_ans

TABLES

t_spopli = i_spopli

EXCEPTIONS

not_enough_answers = 1

too_much_answers = 2

too_much_marks = 3

OTHERS = 4.

CLEAR i_spopli.

LOOP AT i_spopli WHERE selflag EQ 'X'.

ENDLOOP.

Thanks.

5 REPLIES 5

0 Kudos

Hi Alice,

We wont be able to add an if-else statement inside the call function statement.So we can store the multi-lingual texts in an internal table . The internal table should have decription and language key [SPRAS] as fields . Take out the description text according to the language.

Rajesh

Former Member
0 Kudos


if sy-langu = 'E'. 
lfd_text = 'PLEASE SELECT REASON FOR CHANGE'(006).
elseif sy-langu = 'N'.
lfd_text = Translation text.
endif. 

CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
EXPORTING
mark_flag = ' '
mark_max = 1
start_col = 80
start_row = 5
textline1 = lfd_text
titel = 'REASON FOR CHANGE'(002)
IMPORTING
answer = l_ans
TABLES
t_spopli = i_spopli
EXCEPTIONS
not_enough_answers = 1
too_much_answers = 2
too_much_marks = 3
OTHERS = 4.

CLEAR i_spopli.
LOOP AT i_spopli WHERE selflag EQ 'X'.
ENDLOOP.

Hope this helps.

Anju

Former Member
0 Kudos

Hi Alice,

On what basis do you decide the language in which the message needs issued?, if it is the log in language of the end user, then you need to just create the corresponding message as text-elements->Text Symbols within the program in concern. When you do this, you will be able to maintain the texts in different languages and your code will look like something below,


DO.
CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
EXPORTING
mark_flag = ' '
mark_max = 1
start_col = 80
start_row = 5
textline1 = text-001 " Maintained as text element
titel = 'REASON FOR CHANGE'(002)
IMPORTING
answer = l_ans
TABLES
t_spopli = i_spopli
EXCEPTIONS
not_enough_answers = 1
too_much_answers = 2
too_much_marks = 3
OTHERS = 4.

CLEAR i_spopli.
LOOP AT i_spopli WHERE selflag EQ 'X'.
ENDLOOP.

Alternatively, you can maintain this as an entry in a message class, using SE91.

And use the message into text ABAP construct,


      DATA mtext TYPE string. 
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
                INTO mtext 
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
DO.
CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
EXPORTING
mark_flag = ' '
mark_max = 1
start_col = 80
start_row = 5
textline1 = mtext " Maintained as text element
titel = 'REASON FOR CHANGE'(002)
IMPORTING
answer = l_ans
TABLES
t_spopli = i_spopli
EXCEPTIONS
not_enough_answers = 1
too_much_answers = 2
too_much_marks = 3
OTHERS = 4.

CLEAR i_spopli.
LOOP AT i_spopli WHERE selflag EQ 'X'.
ENDLOOP.

Regards,

Chen

Edited by: Chen K V on May 12, 2011 11:42 AM

matt
Active Contributor
0 Kudos

Ignore Rajesh's and Anju's postings - do what Chen said. SAP is designed to be a multilingual system. If you have the Norwegian language installed on your system, there is no need for a change in coding.

'Some text'(002) is handled by the ABAP interpreter exactly in the same way as text-002 I.e. the text appropriate to the logon language is what is actually displayed, regardless of the contents of 'some text'.

The first format is better than the second, as it gives an indication of the content of the text, without having to navigate to the text.

0 Kudos

Definitely Chen's suggestion.