‎2006 Feb 28 1:18 PM
Hello experts,
As being new to ABAP, I was tasked to modify a report. The problem is that when the user enters a material number in the selection screen the report says it didn't found any records. But when they try to enter values on other selection screen select options or parameter the report just works fine. So I debugged the report and I think that it is because of the select statement below. I think it doesn't get any material numbers from table cooi so I was tasked to replace cooi with eban table. So instead of cooi-matnr in so_matnr what I would like to do is eban-matnr in so_matnr. But my problem is how can I link all the tables? if I do a seperate select what would I get and where would I compare it to? hope you could help me guys here. Thanks and take care!
**here is the selection screen**
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: pa_bukrs LIKE t001-bukrs OBLIGATORY DEFAULT 'GLOB'.
SELECT-OPTIONS: so_psphi FOR prps-psphi,
so_ebeln FOR ekko-ebeln,
so_lifnr FOR ekko-lifnr,
so_matnr FOR ekpo-matnr,
so_augdt FOR bseg-augdt.
*PARAMETERS: pa_augdt LIKE bseg-augdt.
SELECTION-SCREEN END OF BLOCK b1.
**here is the code that i think must be modified**
FORM get_data.
IF NOT so_ebeln[] IS INITIAL.
PERFORM get_header.
ENDIF.
SELECT apsphi brefbn b~lifnr
FROM prps AS a INNER JOIN cooi AS b
ON aobjnr = bobjnr
INTO CORRESPONDING FIELDS OF it_hdr
WHERE a~psphi IN so_psphi
AND a~pbukr = pa_bukrs
AND a~erdat LE v_budat
AND a~erdat IN so_augdt
AND b~refbn IN so_ebeln
AND b~lifnr IN so_lifnr
AND b~matnr IN so_matnr
AND b~rfart = 'P'.
SELECT SINGLE name1 FROM lfa1 INTO it_hdr-name1
WHERE lifnr = it_hdr-lifnr.
IF NOT so_augdt[] IS INITIAL.
CLEAR ekko.
SELECT SINGLE * FROM ekko
WHERE ebeln = it_hdr-refbn
AND bedat IN so_augdt.
IF sy-subrc EQ 0.
APPEND it_hdr.
CLEAR it_hdr.
ENDIF.
ELSE.
APPEND it_hdr.
CLEAR it_hdr.
ENDIF.
ENDSELECT.
LOOP AT t_ekpo.
it_hdr-refbn = t_ekpo-ebeln.
it_hdr-lifnr = t_ekpo-lifnr.
it_hdr-name1 = t_ekpo-name1.
APPEND it_hdr. CLEAR it_hdr.
ENDLOOP.
IF it_hdr[] IS INITIAL.
EXIT.
ENDIF.
‎2006 Feb 28 2:53 PM
replace ur select hope this will meet ur requirement
SELECT apsphi brefbn b~lifnr
FROM prps AS a INNER JOIN cooi AS b
ON aobjnr = bobjnr
INNER JOIN eban AS c
ON bmatnr = cmatnr
INTO CORRESPONDING FIELDS OF it_hdr
WHERE a~psphi IN so_psphi
AND a~pbukr = pa_bukrs
AND a~erdat LE v_budat
AND a~erdat IN so_augdt
AND b~refbn IN so_ebeln
AND b~lifnr IN so_lifnr
AND c~matnr IN so_matnr
AND b~rfart = 'P'.
‎2006 Feb 28 1:25 PM
use conversion routine for matnr before select so that u pass the correct format
‎2006 Feb 28 1:26 PM
‎2006 Feb 28 1:31 PM
pass ur matnr to the fn module to get the formatted matnr to be passed to select.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = var_matnr
IMPORTING
OUTPUT = var_matnr
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
use this matnr in select statement
‎2006 Feb 28 1:33 PM
u need to pass all the matnrs (since it is a range ) to the funaction module, may be using loop.
‎2006 Feb 28 1:37 PM
CONVERSION_EXIT_ALPHA_INPUT converts any number into a string fill with zeroes, with the number at the extreme right
use above function. for matnr
regard
vinod
‎2006 Feb 28 1:46 PM
The end user was typing 300275 in the so_matnr in the selection screen. So I checked the the material number and it does exists. So what you mean guys is that even though the user types the correct material number it ends up as being non-existent because it lacks digits? for example 00000300275. Is it because of this?
‎2006 Feb 28 2:15 PM
‎2006 Feb 28 2:20 PM
‎2006 Feb 28 2:53 PM
replace ur select hope this will meet ur requirement
SELECT apsphi brefbn b~lifnr
FROM prps AS a INNER JOIN cooi AS b
ON aobjnr = bobjnr
INNER JOIN eban AS c
ON bmatnr = cmatnr
INTO CORRESPONDING FIELDS OF it_hdr
WHERE a~psphi IN so_psphi
AND a~pbukr = pa_bukrs
AND a~erdat LE v_budat
AND a~erdat IN so_augdt
AND b~refbn IN so_ebeln
AND b~lifnr IN so_lifnr
AND c~matnr IN so_matnr
AND b~rfart = 'P'.