Skip to Content
0
Former Member
Nov 15, 2006 at 04:59 PM

Making IF condition and Read from Dynamic Table

23 Views

Hi guys,

I create a dynamice table, i successfully made a Loop condition to the table in order to process some of the fields, but i need an IF statement in order to make some needed validations, and if this condition is validated I then need to read another table based on the value of a field of the dynamic table.

I really apreciated your help.

Regards,

Eric

PD. I'm anexing part of the code.

DATA ls_fcat TYPE lvc_s_fcat .

DATA w_tabix LIKE sy-tabix.

ADD 1 TO w_tabix.

CLEAR ls_fcat.

ls_fcat-col_pos = w_tabix.

ls_fcat-fieldname = 'OBJID'.

ls_fcat-scrtext_l = 'Puesto de Trabajo'.

ls_fcat-scrtext_m = 'Puesto de Trabajo'.

ls_fcat-scrtext_s = 'Puesto de Trabajo'.

ls_fcat-intlen = '08'.

ls_fcat-outputlen = 08.

ls_fcat-key = 'X'.

APPEND ls_fcat TO p_it_dyncat.

ADD 1 TO w_tabix.

CLEAR ls_fcat.

ls_fcat-col_pos = w_tabix.

ls_fcat-fieldname = 'ARBPL'.

ls_fcat-scrtext_l = 'Puesto de Trabajo'.

ls_fcat-scrtext_m = 'Puesto de Trabajo'.

ls_fcat-scrtext_s = 'Puesto de Trabajo'.

ls_fcat-intlen = '08'.

ls_fcat-outputlen = 08.

ls_fcat-key = 'X'.

APPEND ls_fcat TO p_it_dyncat.

SORT it_zcapacidad1 BY pmnux.

LOOP AT it_zcapacidad1 INTO wa_zcapacidad1.

CLEAR ls_fcat.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = wa_zcapacidad1-pmnux

IMPORTING

output = wa_zcapacidad1-pmnux.

  • Material

ADD 1 TO w_tabix.

ls_fcat-col_pos = w_tabix.

ls_fcat-fieldname = wa_zcapacidad1-pmnux.

ls_fcat-scrtext_l = wa_zcapacidad1-pmnux.

ls_fcat-scrtext_m = wa_zcapacidad1-pmnux.

ls_fcat-scrtext_s = wa_zcapacidad1-pmnux.

ls_fcat-inttype = 'C'.

ls_fcat-intlen = '18'.

ls_fcat-outputlen = 18.

APPEND ls_fcat TO p_it_dyncat.

  • Contador Puesto de Trabajo

ADD 1 TO w_tabix.

ls_fcat-col_pos = w_tabix.

CONCATENATE 'cont_' wa_zcapacidad1-pmnux INTO ls_fcat-fieldname.

CONCATENATE 'cont_' wa_zcapacidad1-pmnux INTO ls_fcat-scrtext_l.

CONCATENATE 'cont_' wa_zcapacidad1-pmnux INTO ls_fcat-scrtext_m.

CONCATENATE 'cont_' wa_zcapacidad1-pmnux INTO ls_fcat-scrtext_s.

ls_fcat-inttype = 'C'.

ls_fcat-intlen = '18'.

ls_fcat-outputlen = 18.

APPEND ls_fcat TO p_it_dyncat.

ENDLOOP.

CLEAR ls_fcat.

ADD 1 TO w_tabix.

ls_fcat-col_pos = w_tabix.

ls_fcat-fieldname = 'ENDZT'.

ls_fcat-scrtext_l = 'Cap. Disp. Men'.

ls_fcat-scrtext_m = 'Cap. Disp. Men'.

ls_fcat-scrtext_s = 'Cap. Disp. Men'.

ls_fcat-inttype = 'C'.

ls_fcat-intlen = '10'.

ls_fcat-outputlen = 10.

APPEND ls_fcat TO p_it_dyncat.

CLEAR ls_fcat.

ADD 1 TO w_tabix.

ls_fcat-col_pos = w_tabix.

ls_fcat-fieldname = 'CAPNP'.

ls_fcat-scrtext_l = 'Cap. Nec. Prod.'.

ls_fcat-scrtext_m = 'Cap. Nec. Prod.'.

ls_fcat-scrtext_s = 'Cap. Nec. Prod.'.

ls_fcat-inttype = 'C'.

ls_fcat-intlen = '10'.

ls_fcat-outputlen = 10.

APPEND ls_fcat TO p_it_dyncat.

CLEAR ls_fcat.

ADD 1 TO w_tabix.

ls_fcat-col_pos = w_tabix.

ls_fcat-fieldname = 'CAPRE'.

ls_fcat-scrtext_l = 'Cap. Restante'.

ls_fcat-scrtext_m = 'Cap. Restante'.

ls_fcat-scrtext_s = 'Cap. Restante'.

ls_fcat-inttype = 'C'.

ls_fcat-intlen = '10'.

ls_fcat-outputlen = 10.

APPEND ls_fcat TO p_it_dyncat.

CLEAR ls_fcat.

ADD 1 TO w_tabix.

ls_fcat-col_pos = w_tabix.

ls_fcat-fieldname = 'MONTADO'.

ls_fcat-scrtext_l = 'Molde Montado'.

ls_fcat-scrtext_m = 'Molde Montado'.

ls_fcat-scrtext_s = 'Molde Montado'.

ls_fcat-inttype = 'C'.

ls_fcat-intlen = '1'.

ls_fcat-outputlen = 1.

APPEND ls_fcat TO p_it_dyncat.

DATA: new_table TYPE REF TO data.

  • Método para crear tabla interna dinámicamente

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_dyncat

IMPORTING

ep_table = new_table.

        • then i fill the table

        ...

        ...

              • Continues with the handle_data_changed event

              DEFINE validar.

              if &1 = 'X'.

              read table it_zcapacidad1 with key arbpl = &2.

              &3 = 'IT_TEMP'.

              &4 = 'WA_TEMP'.

              else.

              &3 = 'IT_ZCAPACIDAD1'.

              &4 = 'WA_ZCAPACIDAD1'.

              endif.

              END-OF-DEFINITION.

              LOOP AT .

              • Limpiamos el valor del campo CAPNP de <tab> para evitar

              • alterar el resultado al modificar los valores de la

              • cantidad propuesta.

              CONCATENATE '

              • Neither the define nor the comented part works... any sugestions?

              validar '-ARBPL' w_it w_wa.

              • IF <wa>-MONTADO EQ 'X'.

              • CONCATENATE '<wa>-' 'ARBPL' INTO w_material.

              • READ TABLE it_zcapacidad1 WITH KEY arbpl = '<wa>-ARBPL'.

              • w_it = 'IT_TEMP'.

              • w_wa = 'WA_TEMP'.

              • ELSE.

              • w_it = 'IT_ZCAPACIDAD1'.

              • w_wa = 'WA_ZCAPACIDAD1'.

              • ENDIF.

              .

              ENDLOOP.

              w_tot = w_pos + w_neg.

              IF w_tot LT 0.

              error_alv '000'

              'Se ha sobrepasado la capacidad disponible'

              'de producción de la planta, se hace necesario'

              'ajustar las cantidades propuestas.'

              ls_mod_cell-fieldname

              ls_mod_cell-row_id.

              ENDIF.

              • Refrescamos el ALV

              refrescar_alv.