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

internal table inside a internal table

former_member202733
Participant
0 Likes
1,325

Hi guys, I know it's a beginner question, but I don't know how do this...

I'm in a OO context and I'm trying to create an internal table which have inside an internal table of bapiret2, to process logs. My goal is process a text files and try to generate loans through the bapi BAPI_LOAN_CONTRACT_CREATE, this bapi returns a internal table of bapiret2 and I would like to add each of this return table to an internal table for after process all lines from the text file save those logs through BAL_LOG_MSG_ADD and BAL_DB_SAVE.

So, I would like to know how declare such structure and how to add the return table from bapi to this internal table and how to retrieve those internal tables which is inside another internal table and pass to BAL_LOG_MSG_ADD.

I appreciate some help.


cheers..


Ronaldo

2 REPLIES 2
Read only

oliver_wurm
Active Participant
0 Likes
937

Hi Ronaldo,

the following code example might help:

method METHOD_1.

  types: BEGIN OF ty_1,

           line type i,

           txt_line type string,

           ret type bapiret2_tab,

         END OF ty_1.

  data: lt_result TYPE TABLE OF ty_1,

        ls_result TYPE ty_1,

        lt_bapiret2 type bapiret2_tab,

        ls_ret TYPE bapiret2.

   

* Example:

  ls_result-line = 1.

  ls_result-txt_line = ' whatsoever '.

  ls_result-ret[] = lt_bapiret2[].

  append ls_result to lt_result.

  ...

  loop at lt_result into ls_result.

    loop at ls_result-ret into ls_ret.

      "write to Application Log

    endloop.

  endloop.

endmethod.

Regards

Oliver

Read only

0 Likes
937

Hi Ronaldo,

Please use the below code.

LOOP AT lt_return INTO ls_return.

       
PERFORM msg_add_log USING ls_return.

       
CLEAR ls_return.

     
ENDLOOP.

FORM msg_add_log  USING is_return TYPE bapiret2.

 
DATA:

    ls_msg
TYPE bal_s_msg.

* define data of message for Application Log

  ls_msg
-msgty     = is_return-type.

  ls_msg
-msgid     = is_return-id.

  ls_msg
-msgno     = is_return-number.

  ls_msg
-msgv1     = is_return-message_v1.

  ls_msg
-msgv2     = is_return-message_v2.

  ls_msg
-msgv3     = is_return-message_v3.

  ls_msg
-msgv4     = is_return-message_v4.



 
CALL FUNCTION 'BAL_LOG_MSG_ADD'

   
EXPORTING

      i_log_handle 
= gv_log_handle

      i_s_msg      
= ls_msg

   
EXCEPTIONS

      log_not_found
= 0

     
OTHERS        = 1.

 
IF sy-subrc <> 0.

   
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

           
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

 
ENDIF.

ENDFORM.                    " MSG_ADD_LOG

Regards,

SPR