cancel
Showing results for 
Search instead for 
Did you mean: 

User Exit help needed

Former Member
0 Kudos
89

Gurus, i need help with CMOD. i am working with 2LIS_02_SRV datasource and have to call a function module. now the issue is the program is working fine when i hard code EBELN number but this is temporary. when my datasource will run it will send a lot of EBELN numbers. what do i put in EXPORTING parameter of the function module? I tried to put C_T_DATA-EBELN but it is empty. i need to know how to dynamically pass EBELN. can some body please help me ?

Thanks.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thank you everyone. i was able to get the code working but the issue is that it is very slow. I think this is due to calling 2 loops? is there a way to fix the performance of this code please? it is producing correct results but it is just too slow and I am not even using REFRESH or CLEAR my internal tables.

DATA: l_s_mc11va0itm LIKE mc11va0itm,

        it_mc11va0itm  TYPE mc11va0itm OCCURS 0.

  DATA: l_tabix        LIKE sy-tabix.

LOOP AT C_T_DATA INTO l_s_mc11va0itm.

l_tabix = sy-tabix.

    CALL FUNCTION 'READ_TEXT'

      EXPORTING

              client                        = sy-mandt

              id                            = '0002'

              language                      = 'E'

              name                          = l_s_mc11va0itm-VBELN

              object                        = 'VBBP'

*             ARCHIVE_HANDLE                = 0

*             LOCAL_CAT                     = ' '

*     IMPORTING

*             HEADER                        =

    TABLES

              lines                         = it_lines1

     EXCEPTIONS

             id                            = 1

             language                      = 2

             name                          = 3

             not_found                     = 4

             object                        = 5

             reference_check               = 6

             wrong_access_to_archive       = 7

             OTHERS                        = 8.

LOOP AT it_lines1 INTO wa_t_it_lines.

IF sy-subrc = 0.

  l_s_mc11va0itm-FIELD1 = wa_t_it_lines-FIELD1.

ENDIF.

ENDLOOP.

MODIFY c_t_data FROM l_s_mc11va0itm INDEX l_tabix.

ENDLOOP.

RafkeMagic
Active Contributor
0 Kudos

Do you have an ABAP developer close by? Check with her/him... quite a few things can be optimized in the above code.

I don't understand the sy-subrc check in the second loop... it can't be <> 0 within the loop?!

Also, once you assign your field in that loop, you should "exit" the loop...

sander_vanwilligen
Active Contributor
0 Kudos

Hi,

I suggest to work with field-symbols. This is much faster. Then the second loop, which logic do you need here? The first record, any record? If you keep the second loop, then use EXIT within the loop. Also here I would define a field-symbol.

Best regards,

Sander

Former Member
0 Kudos

Thank you guys  I can take out sy-subrc in my second loop i am taking the field out of the table which function module returned and assigning it to l_s structure and later modifying my c_t_data structure by l_s structure. is there another way of doing it?

Former Member
0 Kudos

Hi Sunil,

There should never be Loop within Loop. There would be Loop and then Read for better performance. Please explain me the issue properly, i will give u the code.

Thanks,

Karthik

Former Member
0 Kudos

Hello and thank you again everybody.  see i tried to do some changes by using field symbols in the code but performance is still very very bad.

FIELD-SYMBOLS <f1_data> TYPE mc11va0itm.

  LOOP AT c_t_data ASSIGNING <f1_data>.

    CALL FUNCTION 'READ_TEXT'

      EXPORTING

              client                        = sy-mandt

              id                            = '0002'

              language                      = 'E'

              name                          = <f1_data>-VBELN

              object                        = 'VBBP'

    TABLES

              lines                         = it_lines1

    LOOP AT it_lines1 ASSIGNING <f2_data2> from 1 to 1.

      <f1_data>-Field1 = <f2_data2>-Field1.

    ENDLOOP.


Please help.

Thanks.

former_member185132
Active Contributor
0 Kudos

Sorry, that is not quite right. LOOP AT and READ are two very different statements with very different functionalities and behaviour, they cannot be substituted with each other without changing the logic of the program. There is a very small subset of LOOP scenarios that can be reliably replaced by READ. Therefore there are many scenarios where nested loops are unavoidable.

@Sunil, The READ_TEXT FM is probably the reason for the poor performance, as it is reading one for every Sales Ord - so if you have 10000 Sales Orders, this FM will run 10000 times.

See this article for an explanation on how to replace READ_TEXT with code that will pick up the texts at once for several sales orders.

sander_vanwilligen
Active Contributor
0 Kudos

Hi,

Your coding should be processed in the context of a loop over the data package. It should look like this:

field-symbols:

  <data> type mc02m_0srv.

loop at c_t_data assigning <data>.

    CALL FUNCTION 'READ_TEXT'

      EXPORTING

              client                        = sy-mandt

              id                            = '0002'

              language                      = 'E'

              name                          = <data>ebeln  "<<< changed

              object                        = 'VBBP'

*             ARCHIVE_HANDLE                = 0

*             LOCAL_CAT                     = ' '

*     IMPORTING

*             HEADER                        =

    TABLES

              lines                         = it_lines1[]

     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.

    ">>> do here want you need to do <<<

  endif.

endloop.

Best regards,

Sander

Former Member
0 Kudos

this is my code.

  DATA: l_s_mc11va0itm LIKE mc11va0itm,

        it_mc11va0itm  TYPE mc11va0itm OCCURS 0.

  DATA: l_tabix        LIKE sy-tabix.

    CALL FUNCTION 'READ_TEXT'

      EXPORTING

              client                        = sy-mandt

              id                            = '0002'

              language                      = 'E'

              name                          = This is where I want to pass 'vbeln' dynamically but do not know how. if i put C_T_DATA-VBELN, no errors but in debugging it's empty so nothing gets passed.

              object                        = 'VBBP'

*             ARCHIVE_HANDLE                = 0

*             LOCAL_CAT                     = ' '

*     IMPORTING

*             HEADER                        =

    TABLES

              lines                         = it_lines1[]

     EXCEPTIONS

             id                            = 1

             language                      = 2

             name                          = 3

             not_found                     = 4

             object                        = 5

             reference_check               = 6

             wrong_access_to_archive       = 7

             OTHERS                        = 8.

ccc_ccc
Active Contributor
0 Kudos

Hi Sunil,

Please check either C_T_DATA has data before passing, if not debug and check why data is available in C_T_DATA and also check data at table level.

Thank you,

Nanda

RafkeMagic
Active Contributor
0 Kudos

I assume you would like to run this function module for all records in the data package?

In that case, you need to loop the internal table containing that data (c_t_data) and call the function within that loop...

The user exit is called after each data package (not for each line).

Loed
Active Contributor
0 Kudos

Hi Sunil,

As Suhas said, please post the code you are currently using..

Regards,

Loed

former_member185132
Active Contributor
0 Kudos

Please post your current code and explain what you are trying to achieve. Currently it is not very clear.