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

problem populating an internal table

Hello,

I am having a problem with filling an internal table. I cannot seem to grasp this and I struggle with this in every program. I am attaching pieces of my program so that maybe someone can help me. I have a selection screen that I populate with dates. if the dates are populated, I want to use these dates for the selection. If the dates are initial, I want to read an entry from the TVARV table and populate the dates that will used in the selection. I tried various code statements and I cannot get it to work. i get messages like "is a table without a header line and therefore has no component "LOW" or other messages similar to this. I would like that if the s_udate is populated, I could fill the tvarv table and not have to call the form.

also if anyone has some documentation on working with internal tables without header lines (I think I read in here that internal tables without header lines is the way to go ), could you please include that as well so that I could try to understand how this suppose to work

thanks in advance for the help

TYPES: BEGIN OF ty_tvarv_date,

low TYPE tvarv_val, "start date

high TYPE tvarv_val, "end date

END OF ty_tvarv_date.

TYPES: ty_t_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0,

DATA it_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0.

SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 2(22) text-002.

SELECT-OPTIONS s_udate FOR sy-datlo.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK a.

PERFORM select_date_tvarv CHANGING it_tvarv_date.

PERFORM select_data643_mseg USING it_tvarv_date

it_zfi_gl_subcontrk[]

CHANGING it_mseg643.

<b>*******************************************************************</b>

FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.

IF s_udate IS INITIAL.

SELECT low high

FROM tvarv

INTO TABLE p1_it_tvarv_date

WHERE name EQ 'Z_SUBCONTRK_DATES'.

IF sy-subrc NE 0.

IF sy-batch IS INITIAL.

MESSAGE i899 WITH text-027.

LEAVE LIST-PROCESSING.

ELSE.

MESSAGE e899 WITH text-027.

ENDIF.

ENDIF.

ELSE.

  • MOVE s_udate to p1_it_tvarv_date.

  • MOVE s_udate-low(8) to p1_it_tvarv_date-low.

  • MOVE s_udate-high(8) to p1_it_tvarv_date-high.

ENDIF.

ENDFORM. " FORM SELECT_DATE_TVARV

<b>*******************************************************************</b>

FORM select_data643_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date

p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk

CHANGING p1_it_mseg TYPE ty_t_mseg643.

DATA: wa_tvarv_date type ty_tvarv_date.

READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.

SELECT abukrs awerks amatnr aerfmg a~erfme

akostl abwart amblnr awempf acharg akzbew algort bbudat

FROM mseg AS a INNER JOIN mkpf AS b ON amblnr EQ bmblnr

AND b~budat <= wa_tvarv_date-high

AND b~budat >= wa_tvarv_date-low

INTO TABLE p1_it_mseg

FOR ALL ENTRIES IN p1_zfi_gl_subcontrk

WHERE a~bukrs EQ p1_zfi_gl_subcontrk-bukrs_from

AND a~werks EQ p1_zfi_gl_subcontrk-werks_from

AND a~wempf EQ p1_zfi_gl_subcontrk-werks_to643

AND a~matnr EQ p1_zfi_gl_subcontrk-matnr

AND a~bwart EQ'643'.

IF sy-subrc NE 0.

IF sy-batch IS INITIAL.

MESSAGE i899 WITH text-027.

LEAVE LIST-PROCESSING.

ELSE.

MESSAGE e899 WITH text-027.

ENDIF.

ENDIF.

ENDFORM. " FORM SELECT_DATA643_MSEG

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on May 29, 2007 at 06:57 PM
    FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.
    
      DATA: wa_tvarv_date TYPE ty_tvarv_date.
      IF s_udate[] IS INITIAL.
    *-- If date is not entered in the selection screen
        SELECT low high FROM tvarv
                        INTO TABLE p1_it_tvarv_date
                       WHERE name EQ 'Z_SUBCONTRK_DATES'.
        IF sy-subrc NE 0.
          IF sy-batch IS INITIAL.
            MESSAGE i899 WITH text-027.
            LEAVE LIST-PROCESSING.
          ELSE.
            MESSAGE e899 WITH text-027.
          ENDIF.
        ENDIF.
      ELSE.
        MOVE: s_udate-low(8)  TO wa_tvarv_date-low,
              s_udate-high(8) TO wa_tvarv_date-high.
        APPEND wa_tvarv_date TO p1_it_tvarv_date.
      ENDIF.
    
    ENDFORM. " FORM SELECT_DATE_TVARV
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 29, 2007 at 06:54 PM

    See the code below. I think you can do the reverse with s_update.

    TYPES: BEGIN OF ty_tvarv_date,

    low TYPE tvarv_val, "start date

    high TYPE tvarv_val, "end date

    END OF ty_tvarv_date.

    TYPES: ty_t_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0,

    DATA it_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date <b>WITH HEADER LINE</b> INITIAL SIZE 0.

    SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.

    SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 2(22) text-002.

    SELECT-OPTIONS s_udate FOR sy-datlo.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN END OF BLOCK a.

    PERFORM select_date_tvarv CHANGING it_tvarv_date.

    PERFORM select_data643_mseg USING it_tvarv_date

    it_zfi_gl_subcontrk[]

    CHANGING it_mseg643.

    *******************************************************************

    FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.

    IF s_udate IS INITIAL.

    SELECT low high

    FROM tvarv

    INTO TABLE p1_it_tvarv_date

    WHERE name EQ 'Z_SUBCONTRK_DATES'.

    IF sy-subrc NE 0.

    IF sy-batch IS INITIAL.

    MESSAGE i899 WITH text-027.

    LEAVE LIST-PROCESSING.

    ELSE.

    MESSAGE e899 WITH text-027.

    ENDIF.

    ENDIF.

    ELSE.

    <b>LOOP AT p1_it_tvarv_date.

    clear s_update.

    s_update-sign = 'I'.

    s_update-option = 'EQ'.

    s_update-low = p1_it_tvarv_date-low.

    s_update-low = p1_it_tvarv_date-high.

    append s_update.

    endloop.</b>

    ENDIF.

    ENDFORM. " FORM SELECT_DATE_TVARV

    *******************************************************************

    FORM select_data643_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date

    p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk

    CHANGING p1_it_mseg TYPE ty_t_mseg643.

    DATA: wa_tvarv_date type ty_tvarv_date.

    SELECT abukrs awerks amatnr aerfmg a~erfme

    akostl abwart amblnr awempf acharg akzbew algort bbudat

    FROM mseg AS a INNER JOIN mkpf AS b ON amblnr EQ bmblnr

    INTO TABLE p1_it_mseg

    FOR ALL ENTRIES IN p1_zfi_gl_subcontrk

    WHERE a~bukrs EQ p1_zfi_gl_subcontrk-bukrs_from

    AND a~werks EQ p1_zfi_gl_subcontrk-werks_from

    AND a~wempf EQ p1_zfi_gl_subcontrk-werks_to643

    AND a~matnr EQ p1_zfi_gl_subcontrk-matnr

    AND a~bwart EQ'643'

    <b>AND b~budat IN s_udpate</b>.

    IF sy-subrc NE 0.

    IF sy-batch IS INITIAL.

    MESSAGE i899 WITH text-027.

    LEAVE LIST-PROCESSING.

    ELSE.

    MESSAGE e899 WITH text-027.

    ENDIF.

    ENDIF.

    ENDFORM. " FORM SELECT_DATA643_MSEG

    Add a comment
    10|10000 characters needed characters exceeded

    • In tables with header line, you need not define an explicit work area.

      System will create a so-called work area, which is called header line.

      This header line is like any other work area. the difference is that it can be accessed using internal table name. A record will be by default read into header line in a READ statement.

      For ex,

      READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.

      Here you used to read the 1st record into wa_tvarv_date.

      But after making it table with header line you can use

      READ TABLE p1_tvarv_date INDEX 1.

      This will move the data to header line and it can be accessed by name p1_tvarv_date.

      See the code below.

      TYPES: BEGIN OF ty_tvarv_date,

      low TYPE tvarv_val, "start date

      high TYPE tvarv_val, "end date

      END OF ty_tvarv_date.

      TYPES: ty_t_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0,

      DATA it_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date <b>WITH HEADER LINE INITIAL</b> SIZE 0.

      SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.

      SELECTION-SCREEN BEGIN OF LINE.

      SELECTION-SCREEN COMMENT 2(22) text-002.

      SELECT-OPTIONS s_udate FOR sy-datlo.

      SELECTION-SCREEN END OF LINE.

      SELECTION-SCREEN END OF BLOCK a.

      PERFORM select_date_tvarv CHANGING it_tvarv_date.

      PERFORM select_data643_mseg USING it_tvarv_date

      it_zfi_gl_subcontrk[]

      CHANGING it_mseg643.

      *******************************************************************

      FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.

      IF s_udate IS INITIAL.

      SELECT low high

      FROM tvarv

      INTO TABLE p1_it_tvarv_date

      WHERE name EQ 'Z_SUBCONTRK_DATES'.

      IF sy-subrc NE 0.

      IF sy-batch IS INITIAL.

      MESSAGE i899 WITH text-027.

      LEAVE LIST-PROCESSING.

      ELSE.

      MESSAGE e899 WITH text-027.

      ENDIF.

      ENDIF.

      ELSE.

      • MOVE s_udate to p1_it_tvarv_date.

      • MOVE s_udate-low(8) to p1_it_tvarv_date-low.

      • MOVE s_udate-high(8) to p1_it_tvarv_date-high.

      ENDIF.

      ENDFORM. " FORM SELECT_DATE_TVARV

      *******************************************************************

      FORM select_data643_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date

      p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk

      CHANGING p1_it_mseg TYPE ty_t_mseg643.

      <b>READ TABLE p1_tvarv_date INDEX 1.</b>

      SELECT abukrs awerks amatnr aerfmg a~erfme

      akostl abwart amblnr awempf acharg akzbew algort bbudat

      FROM mseg AS a INNER JOIN mkpf AS b ON amblnr EQ bmblnr

      <b>AND b~budat <= p1_tvarv_date-high

      AND b~budat >= p1_tvarv_date-low</b>

      INTO TABLE p1_it_mseg

      FOR ALL ENTRIES IN p1_zfi_gl_subcontrk

      WHERE a~bukrs EQ p1_zfi_gl_subcontrk-bukrs_from

      AND a~werks EQ p1_zfi_gl_subcontrk-werks_from

      AND a~wempf EQ p1_zfi_gl_subcontrk-werks_to643

      AND a~matnr EQ p1_zfi_gl_subcontrk-matnr

      AND a~bwart EQ'643'.

      IF sy-subrc NE 0.

      IF sy-batch IS INITIAL.

      MESSAGE i899 WITH text-027.

      LEAVE LIST-PROCESSING.

      ELSE.

      MESSAGE e899 WITH text-027.

      ENDIF.

      ENDIF.

      ENDFORM. " FORM SELECT_DATA643_MSEG

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.