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

Is it possible to call the Function Module in the Constructing operator of ABAP 7.4 code?

Former Member
0 Likes
4,190

Hi All,

Is it possible to call the Function Module in construction operator, like is it possible to make the below as one line?
kind of LW_OUTPUT_H-SL_TEXT = VALUE #( ......... )?

DATA : LT_TEXT TYPE TABLE OF bapisdtehd,.

TRY.
DATA(lw_text) = lt_text[ sd_doc = '1234567890' ].
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = lw_text-text_id
language = sy-langu
name = lw_text-text_name
object = lw_text-applobject
TABLES
lines = lt_tline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc = 0.
lw_output_h-sl_text = REDUCE #( INIT x TYPE string
FOR lw_tline IN lt_tline
NEXT x = x && lw_tline-tdline ).
ENDIF.
CATCH cx_sy_itab_line_not_found.

ENDTRY.

1 ACCEPTED SOLUTION
Read only

keremkoseoglu
Contributor
0 Likes
2,353

Write a method which calls the function module & returns a value, and call the method inline.

Pseudo-sample:

METHODS my_meth 
IMPORTING !iv_import TYPE some_type
RETURNING VALUE(rv_value) TYPE some_type2. ... METHOD my_meth. CALL FUNCTION 'MY_FUNC'
EXPORTING
iv_value = iv_import
IMPORTING
ev_value = rv_value. ENDMETHOD. ... ls_output-text = CONV #( my_meth( ls_output-something ) ).
5 REPLIES 5
Read only

keremkoseoglu
Contributor
0 Likes
2,354

Write a method which calls the function module & returns a value, and call the method inline.

Pseudo-sample:

METHODS my_meth 
IMPORTING !iv_import TYPE some_type
RETURNING VALUE(rv_value) TYPE some_type2. ... METHOD my_meth. CALL FUNCTION 'MY_FUNC'
EXPORTING
iv_value = iv_import
IMPORTING
ev_value = rv_value. ENDMETHOD. ... ls_output-text = CONV #( my_meth( ls_output-something ) ).
Read only

0 Likes
2,353

Hi Kerem Koseoglu,

I tried using the Method and calling FM inside method and tried the below ways...

The below is working

lt_tline = fill_text( EXPORTING t_text = lt_text i_docno = lw_header-doc_number ) .
lw_output_h-sl_text = REDUCE #( INIT x TYPE string FOR lw_tline IN lt_tline NEXT x = x && lw_tline-tdline ).

The Below is not working, is there any operator I can make use to use in one line? Sorry if my ask is not correct..

lw_output_h-sl_text = REDUCE #( INIT x TYPE string FOR lw_tline IN ...lt_tline... = fill_text( EXPORTING t_text = lt_text i_docno = lw_header-doc_number )    NEXT x = x && lw_tline-tdline ).
Read only

2,353
vmohan.kumar doesn't it work? what syntax error do you get? :

lw_output_h-sl_text =REDUCE #( INIT x TYPE string

FOR lw_tline IN fill_text( t_text = lt_text i_docno = lw_header-doc_number )

NEXT x = x && lw_tline-tdline ).

Read only

2,353

Hi Sandra Rossi,

its my mistake to try like ....LW_TLINE IN LT_TLINE = FILL_TEXT...so on..
the way you have sent is working.........Thanks a lot for your reply...

I am changing this thread as Answered..but not sure how to make your comment as answer..

Regards,
VMKumar

Read only

0 Likes
2,353

vmohan.kumar you're welcome. I could convert my comment into an answer, but anyway the most important thing for the forum is that your issue and solution are searchable, which is not the case because the title and question don't show the real problem, so probably people won't even look at the answer and comments. Of the importance of being the most precise possible...