Field symbols

Colapsar
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • cirsgo
    Junior Member
    • jun
    • 11

    #1

    Field symbols

    Hola qué tal,

    Soy nuevo por aquí y tengo un problema para optimizar un código que me han dicho debo hacerlo con field symbols. Adjunto trozo de código:

    Previamente a esto hay un select single * tabla que me informa la cabecera l_wa_tabla y en esa están todos los tpr*...cómo hago esto con field symbols????

    case sy-datum+6(2).
    when '01'.
    move l_wa_tabla-tpr01 to grid_tab-tprog.
    when '02'.
    move l_wa_tabla-tpr02 to grid_tab-tprog.
    when '03'.
    move l_wa_tabla-tpr03 to grid_tab-tprog.
    .
    .
    .
    etc.
    endcase.


    Haber si alguien puede ayudar por favor!!!! Muchas gracias!!!
  • ibai23
    Junior Member
    • mar
    • 19

    #2
    Hola,

    prueba con este codigo de ejemplo que te mando:

    Código:
    *DATOS DE EJEMPLO
    types: begin of l_wa_tabla,
      tpr01(2) type c,
      tpr02(2) type c,
      tpr03(2) type c,
      tpr04(2) type c,
      tpr05(2) type c,
      tpr06(2) type c,
      tpr07(2) type c,
      tpr08(2) type c,
      tpr09(2) type c,
      tpr10(2) type c,
      tpr11(2) type c,
      tpr12(2) type c,
    END OF l_wa_tabla.
    data: l_wa_tabla type l_wa_tabla. "ESTRUCTURA PARA EL EJEMPLO
    *data: lw_local(2) type c. "
    data: lv_indice(2) TYPE c. "VARIABLE PARA EL INDICE
    data: lv_campo(16) type c. "VARIABLE PARA EL FIELD SYMBOL
    FIELD-SYMBOLS: <fs_test> type CHAR2. "FIELD SYMBOL
    
    do 12 times.
    *asignamos el nº de vuelta del loop a la variable de caracter.
      lv_indice = sy-INDEX.
    *le ponemos el cero a la izquierda
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT         = lv_indice
       IMPORTING
         OUTPUT        = lv_indice.
    *concatenamos para crear el field symbol
      CONCATENATE 'L_WA_TABLA-TPR' lv_indice into lv_campo.
    *asignamos el field symbol
      ASSIGN (lv_campo) to <fs_test>.
    *en <fs_test> tienes el valor correspondiente al campo de L_WA_TABLA
    
    enddo.

    Comentario

    • cirsgo
      Junior Member
      • jun
      • 11

      #3
      Muchas gracias, he adaptado lo que me pones y perfecto !!!

      Gracias!!!

      Comentario

      Trabajando...