Skip to Content
author's profile photo Former Member
Former Member

translate field of many internal table in one go

Hello,

i know i can translate a field of particular internal table to upper case using keyword 'TRANSLATE itab-field TO UPPER CASE'.

my requirement is i have 15 internal table. i want to create one subroutine which if given name of internal table will convert all the lower case values in that table to upper case.

data : int_table(50).

int_table = 'name_of_internal_table'.

perform translate_to_upper_case using int_table.

is this possible, is there any FM for this.

please advice.

regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 04, 2005 at 08:00 AM

    Hi,

    The code you have written is correct.

    But pass the parameter field as <b>CHANGING</b> not

    <b>USING</b>. Within the implementation part of this

    perform wirte this.

    FORM translate_to_upper_case <b>CHANGING</b> int_table1

    LOOP at int_table1.

    TRANSLATE int_table1-field TO UPPER CASE.

    MODIFY int_table 1.

    ENDLOOP.

    ENDFORM.

    Ensure that the contents of the internal table are characters or texts.

    Please reward points if this explanation is useful.

    Regards,

    Siva

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      when you run this statament:

      ASSIGN (P_INT_TABLE) TO <TABLE>.

      an error occurs because the field-symbols <TABLE> is a table and you are probably assigning the workarea of P_INT_TABLE and not all data of P_INT_TABLE.

      When you want to pass whole table to field-symbols if P_INT_TABLE is only the name of internal table you should write:

      DATA: ALL_TABLE(3O) TYPE C.

      CONCATENATE P_INT_TABLE '[]' INTO ALL_TABLE.

      ASSIGN (ALL_TABLE) TO <TABLE>.

      Or you change the type of parameter of form:

      FORM TRANSLATE_TO_UPPER_CASE

      USING P_INT_TABLE TYPE TABLE.

      Now you write:

      ASSIGN P_INT_TABLE TO <TABLE>.

      But when you run this routine you have to write:

      PERFORM TRANSLATE_TO_UPPER_CASE MY_YABLE[].

      Anyway in this case the field-symbols <TABLE> is useless because you can directly use the parameter:

      FORM TRANSLATE_TO_UPPER_CASE

      USING P_INT_TABLE TYPE TABLE.

      FIELD-SYMBOLS: <WA> TYPE ANY.

      LOOP AT P_INT_TABLE ASSIGNING <WA>.

      TRANSLATE <WA> TO UPPER CASE.

      ENDLOOP.

      ENDFORM.

      Max

  • author's profile photo Former Member
    Former Member
    Posted on Oct 04, 2005 at 07:56 AM

    Hi,

    Try this.

    form translator_to_upper_case using tab_name.

    field-symbols: <itab> type standard table,

    <wa> type any.

    assign (tab_name) to <itab>.

    loop at <itab> assigning <wa>.

    TRANSLATE <wa> TO UPPER CASE.

    endloop.

    endform.

    Svetlin

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Svetlin,

      this is great logic, but very tedious, so i stick to my old logic.

      But i need your advice in following logic given by you

      form translator_to_upper_case using tab_name.

      field-symbols: <itab> type standard table,

      <wa> type any.

      assign (tab_name) to <itab>.

      loop at <itab> assigning <wa>.

      TRANSLATE <wa> TO UPPER CASE.

      endloop.

      endform.

      i was trying this, but at runtime i get error

      ASSIGN_TYPE_CONFLICT

      for code :: assign (tab_name) to <itab>.

      please advice how to remove this

      regards

  • Posted on Oct 04, 2005 at 08:01 AM

    This is just pseudocode but you will get the idea.

    In this case you do not pass the name of the internal table but the internal table itself

    p_field is the field to be translated.

    perform translate_table using 'COMPONENT' int_table[].

    HTH

    Christian

    form translate_table using p_field type dd02l-fieldname
                         changing pit_itab type any table.
    
      field-symbols: <l_field> type any. 
      field-symbols: <lwa_line> type any. 
    
      loop at pit_itab assigning <lwa_line>. 
        assign component (p_field) of structure <lwa_line>
                                   to <L_field>. 
        if sy-subrc ne 0. exit. endif. 
           translate <l_field> to upper case.  
        endif. 
     endloop.  
    endform. 
    

    Message was edited by: Christian Finkbeiner

    Ahh too slow....

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.