‎2007 May 25 8:09 PM
Hello,
I have two selects where I am trying to select records from the MSEG table. I am using the FOR ALL ENTRIES IN to select the based on the records from my work table.
the two selects both use the same work table. I have a field in the work table that is set up with the domain text5. I have a 5 character value in the field. I am trying to select records where the field wempf (char 12) equals this 5 char field and in the other select I am trying to select records where the field lifnr (char 10) equals this 5 char field.
I am not sure if this can be done using the 1 field or if I have to create a field with the length of 12 and a field with a length of 10 in order to get my two selects to work.
thanks in advance for the help
‎2007 May 25 8:16 PM
When you use FOR ALL ENTRIES all key fields must be the same type and lenght....
You can't do this....
*Field1 --> Char 5
*My_Tab-Field1 --> Char 10
FOR ALL ENTRIES IN MY_TAB
WHERE FIELD1 EQ MY_TAB-FIELD1
Greetings,
Blag.
‎2007 May 25 8:15 PM
can i have your code ?
source field properties should match target field ..
‎2007 May 25 8:18 PM
here is the code that hs the structure defined and the two selects. the statement in question is in bold
TYPES: BEGIN OF ty_zfi_gl_subcontrk,
bukrs_from TYPE zz_bukrs_fr, "Company Code From
bukrs_to TYPE zz_bukrs_to, "Company Code To
werks_virtual TYPE zz_werks_vir, "Plant Virtual
werks_from TYPE zz_werks_fr, "Plant From
werks_to TYPE zz_werks_to, "Plant To
werks_select TYPE zz_werks_select, "Plant Select
bwart TYPE bwart, "Movement Type (Inventory Management)
matnr TYPE matnr, "Material Number
saknr TYPE saknr, "G/L account number
cfmefac TYPE cfmefac, "Quantity factor
conv_matnr TYPE matnr, "Conversion material number
END OF ty_zfi_gl_subcontrk.
$$----
$$ Form SELECT_DATA643_MSEG
$$----
Check for the data existance in table MSEG for the select query
*----
FORM select_data643_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date
p1_tvarv_time TYPE ty_t_tvarv_time
p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk
CHANGING p1_it_mseg TYPE ty_t_mseg643.
Internal table declaration for tvarv_date - this works
DATA: wa_tvarv_date type ty_tvarv_date.
DATA: wa_tvarv_time type ty_tvarv_time.
READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.
READ TABLE p1_tvarv_time INTO wa_tvarv_time 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
<b>AND awempf EQ p1_zfi_gl_subcontrk-werks_select</b> AND amatnr EQ p1_zfi_gl_subcontrk-matnr
AND a~bwart EQ'643'.
Issue error message if the select fails
IF sy-subrc NE 0.
check for back ground mode
IF sy-batch IS INITIAL.
MESSAGE i899 WITH text-027.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e899 WITH text-027.
ENDIF.
ELSE.
NOTE !!! ****************************************
move system date and time to work areas for updating tvatrv table
upon successful completion of program
***************************************************************************
Sort the internal table for binary search later
SORT p1_it_mseg BY bukrs prctr DESCENDING matnr ASCENDING werks .
ENDIF.
ENDIF.
ENDFORM. " FORM SELECT_DATA643_MSEG
$$----
$$ Form SELECT_DATA101_MSEG
$$----
Check for the data existance in table MSEG for the select query
*----
FORM select_data101_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date
p1_tvarv_time TYPE ty_t_tvarv_time
p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk
CHANGING p1_it_mseg TYPE ty_t_mseg643.
Internal table declaration for tvarv_date - this works
DATA: wa_tvarv_date type ty_tvarv_date.
DATA: wa_tvarv_time type ty_tvarv_time.
READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.
READ TABLE p1_tvarv_time INTO wa_tvarv_time 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_to
AND a~werks EQ p1_zfi_gl_subcontrk-werks_to
<b>AND a~lifnr EQ p1_zfi_gl_subcontrk-werks_select</b>
AND a~matnr EQ p1_zfi_gl_subcontrk-matnr
AND a~bwart EQ'101'.
Issue error message if the select fails
IF sy-subrc NE 0.
check for back ground mode
IF sy-batch IS INITIAL.
MESSAGE i899 WITH text-027.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e899 WITH text-027.
ENDIF.
ELSE.
ENDIF.
ENDFORM. " FORM SELECT_DATA101_MSEG
‎2007 May 25 8:24 PM
Correct logic and as long as both values are same then you will get results ..
otherwise ur select query failed.
wempf (char 12) equals this 5 char field - instead of doing this
within loop
loop at itab.
if wempf+0(5) = ur field
else.
continue.
endif.
endloop.
Reward Points if it is helpful
Thanks
Seshu
‎2007 May 25 8:16 PM
When you use FOR ALL ENTRIES all key fields must be the same type and lenght....
You can't do this....
*Field1 --> Char 5
*My_Tab-Field1 --> Char 10
FOR ALL ENTRIES IN MY_TAB
WHERE FIELD1 EQ MY_TAB-FIELD1
Greetings,
Blag.