Application Development 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: 

dynamic internal table!!

Former Member
0 Kudos

hi

i hav created a dynamic internal table


  LOOP AT I_MARD INTO L_WA_MARD.
      ld_tabix = sy-tabix.
      if ld_tabix eq '30'.
        exit.
      endif.

      CONCATENATE 'LABST'
                  ld_tabix
      INTO xfc-fieldname.
      xfc-tabname   = 'I_OUTPUT-LABST'.
      xfc-ref_field = 'LABST'.
      xfc-ref_table = 'MARD'.

      APPEND xfc TO ifc.
      CLEAR: xfc.
    ENDLOOP.

    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = ifc
      IMPORTING
        ep_table        = dy_table.

    ASSIGN dy_table->* TO <dyn_table>.

    CREATE DATA dy_line LIKE LINE OF <dyn_table>.
    ASSIGN dy_line->* TO <dyn_wa>.
    LOOP AT I_MARD INTO L_WA_MARD WHERE MATNR = L_WA_ITEM-MATNR.

      ld_index = sy-tabix + 1.
      ASSIGN COMPONENT ld_index OF STRUCTURE <dyn_wa> TO <dyn_field>.

      IF sy-subrc EQ 0.
        <dyn_field> = L_WA_MARD-labst.
      ENDIF.
* dynamic 1 to n missing to be corrected
      CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
        EXPORTING
          I_MATNR              = L_WA_ITEM-MATNR
          I_IN_ME              = L_WA_ITEM-MEINS
          I_OUT_ME             = P_MEINH
          I_MENGE              = L_WA_MARD-LABST
        IMPORTING
          E_MENGE              = V_MENGE
        EXCEPTIONS
          ERROR_IN_APPLICATION = 1
          ERROR                = 2.
      MOVE V_MENGE TO I_OUTPUT-LABSTALT.
      clear: v_menge.

    ENDLOOP.

    APPEND <dyn_wa> TO <dyn_table>.
    CLEAR: <dyn_wa>.

now for each L_WA_MARD-labst

i have to pass the value to 'MD_CONVERT_MATERIAL_UNIT'and in turn create another dynamic internal table n move the corresponding value accordingly..whats shall my code shud look like?>

Points for sure

Regards

Gunjan

2 REPLIES 2

Former Member
0 Kudos

Hi,

You want to create a new dynamic internal table?

Former Member
0 Kudos

HI,

use below logic and change your code accordingly

DATA V_FORM TYPE P.

DATA: SYNTAX_CHECK_MSG(240),

SYNTAX_CHECK_LINE TYPE I,

SYNTAX_CHECK_WORD(72).

DATA SOURCE_TAB(72) OCCURS 0 WITH HEADER LINE.

DATA V_SPACE TYPE C VALUE ''''.

APPEND 'Program zformula.' TO SOURCE_TAB..

APPEND 'form calculate_formula changing form_value.' TO SOURCE_TAB.

APPEND 'compute form_value = ' TO SOURCE_TAB.

CONCATENATE V_SPACE '67.341667' V_SPACE INTO SOURCE_TAB.

APPEND SOURCE_TAB.

SOURCE_TAB = '+'.

APPEND SOURCE_TAB.

CONCATENATE V_SPACE '1.240000 ' V_SPACE INTO SOURCE_TAB.

APPEND SOURCE_TAB.

APPEND '.' TO SOURCE_TAB.

CONCATENATE 'write' '/' 'form_value' INTO SOURCE_TAB SEPARATED

BY SPACE.

APPEND SOURCE_TAB.

APPEND '.' TO SOURCE_TAB.

APPEND 'ENDFORM.' TO SOURCE_TAB.

SYNTAX-CHECK FOR SOURCE_TAB MESSAGE SYNTAX_CHECK_MSG

LINE SYNTAX_CHECK_LINE

WORD SYNTAX_CHECK_WORD.

DATA Z_SEQ_NO(4) TYPE N.

DO 20001 TIMES.

DATA Z_REPID LIKE SY-REPID.

Z_REPID = 'ZTEST_DEM'.

INSERT REPORT Z_REPID FROM SOURCE_TAB.

GENERATE REPORT Z_REPID.

IF SY-SUBRC NE 0.

DO 1000 TIMES.

GENERATE REPORT Z_REPID.

IF SY-SUBRC = 0.

EXIT.

ENDIF.

ENDDO.

ENDIF.

PERFORM CALCULATE_FORMULA IN PROGRAM (Z_REPID)

CHANGING V_FORM.

DELETE REPORT Z_REPID.

Regards

amole