Skip to Content
0
Former Member
May 29, 2007 at 06:34 PM

problem populating an internal table

49 Views

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