Application Development and Automation 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: 
Read only

question on selection field

Former Member
0 Likes
1,403

I am trying to code in my program, the ability to either select the vendor information by the vendor number that is entered on the selection which could be blank in which case I would select all vendors or by passing a vendor number from a table that I have created in the program. I have even went as far a concatenating the IEQ in front of the vendor number. when I use the vendor from the internal table, I still get all of the vendors and not just the one that I want

can someone take a look at this code and let me know what I am doing wrong. (this is just a sample and not the entire program)

SELECT-OPTIONS : so_cocod FOR l_bukrs,

so_lifnr FOR l_lifnr,

so_udate FOR l_udate.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION. "Main logic

IF so_udate IS NOT INITIAL.

perform extract_change_data.

LOOP at it_cdhdr into st_cdhdr.

CONCATENATE 'IEQ' st_cdhdr-objectid INTO so_lifnr.

perform extract_vendor_data.

ENDLOOP.

ELSE.

perform extract_vendor_data.

ENDIF.

FORM extract_change_data.

SELECT distinct objectid

INTO TABLE it_cdhdr

FROM cdhdr

WHERE objectclas = 'KRED'

AND udate in so_udate.

ENDFORM. " xtract_change_data.

FORM extract_vendor_data.

SELECT

lfb1lifnr lfb1bukrs lfm1ekorg lfa1ktokk adrcname1 adrcname2

INTO TABLE it_sap_data

FROM ( lfb1 INNER JOIN lfa1 ON lfb1lifnr EQ lfa1lifnr )

LEFT OUTER JOIN adrc ON lfa1adrnr EQ adrcaddrnumber

LEFT OUTER JOIN lfm1 ON lfa1lifnr EQ lfm1lifnr

WHERE lfa1~lifnr IN so_lifnr AND

lfb1~bukrs IN so_cocod.

ENDFORM. "extract_vendor_data.

thanks in advance for the help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,297

Try:


CONCATENATE 'IEQ' st_cdhdr-objectid INTO so_lifnr.
APPEND so_lifnr.

Rob

I am trying to code in my program, the ability to either select the vendor information by the vendor number that is entered on the selection which could be blank in which case I would select all vendors or by passing a vendor number from a table that I have created in the program. I have even went as far a concatenating the IEQ in front of the vendor number. when I use the vendor from the internal table, I still get all of the vendors and not just the one that I want

can someone take a look at this code and let me know what I am doing wrong. (this is just a sample and not the entire program)

SELECT-OPTIONS : so_cocod FOR l_bukrs,

so_lifnr FOR l_lifnr,

so_udate FOR l_udate.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION. "Main logic

IF so_udate IS NOT INITIAL.

perform extract_change_data.

LOOP at it_cdhdr into st_cdhdr.

CONCATENATE 'IEQ' st_cdhdr-objectid INTO so_lifnr.

perform extract_vendor_data.

ENDLOOP.

ELSE.

perform extract_vendor_data.

ENDIF.

FORM extract_change_data.

SELECT distinct objectid

INTO TABLE it_cdhdr

FROM cdhdr

WHERE objectclas = 'KRED'

AND udate in so_udate.

ENDFORM. " xtract_change_data.

FORM extract_vendor_data.

SELECT

lfb1lifnr lfb1bukrs lfm1ekorg lfa1ktokk adrcname1 adrcname2

INTO TABLE it_sap_data

FROM ( lfb1 INNER JOIN lfa1 ON lfb1lifnr EQ lfa1lifnr )

LEFT OUTER JOIN adrc ON lfa1adrnr EQ adrcaddrnumber

LEFT OUTER JOIN lfm1 ON lfa1lifnr EQ lfm1lifnr

WHERE lfa1~lifnr IN so_lifnr AND

lfb1~bukrs IN so_cocod.

ENDFORM. "extract_vendor_data.

thanks in advance for the help

10 REPLIES 10
Read only

Former Member
0 Likes
1,297

Hi,

Use inner join instead of Left outer join.

regards,

Vara

Read only

Former Member
0 Likes
1,297

the select is just a sample of he full select that is in my program. I can include the full select if you wish. one more point - if I code the vendor number on the selection screen, the select will extract only that vendor. I am not sure why I just can fill the so_lifnr field with the vendor number from the internal table and have it select only that vendor.

Read only

0 Likes
1,297

Hi,

Try this...

Instead of

CONCATENATE 'IEQ' st_cdhdr-objectid INTO so_lifnr.

use

so_lifnr = st_cdhdr-objectid+0(10).

In the form extract_vendor_data

SELECT

lfb1lifnr lfb1bukrs lfm1ekorg lfa1ktokk adrcname1 adrcname2

INTO TABLE it_sap_data

FROM ( lfb1 INNER JOIN lfa1 ON lfb1lifnr EQ lfa1lifnr )

LEFT OUTER JOIN adrc ON lfa1adrnr EQ adrcaddrnumber

LEFT OUTER JOIN lfm1 ON lfa1lifnr EQ lfm1lifnr

WHERE lfa1~lifnr = so_lifnr AND

lfb1~bukrs IN so_cocod.

ENDFORM. "extract_vendor_data.

Regards,

Vara

Read only

Former Member
0 Likes
1,297

Instead of using select option just try FOR ALL entries in the second table. That might be better.

Besides this query has 4 tables, i believe this is not a good approach,


SELECT lfb1~lifnr lfb1~bukrs lfm1~ekorg lfa1~ktokk adrc~name1 adrc~name2

INTO TABLE it_sap_data
FROM ( lfb1 INNER JOIN lfa1 ON lfb1~lifnr EQ lfa1~lifnr )
LEFT OUTER JOIN adrc ON lfa1~adrnr EQ adrc~addrnumber
LEFT OUTER JOIN lfm1 ON lfa1~lifnr EQ lfm1~lifnr
WHERE lfa1~lifnr IN so_lifnr AND
lfb1~bukrs IN so_cocod.

Regards

Kathirvel

Read only

Former Member
0 Likes
1,297

Hi Timothy,

LOOP at it_cdhdr into st_cdhdr.

CONCATENATE 'IEQ' st_cdhdr-objectid INTO so_lifnr.

<b>perform extract_vendor_data.</b>

ENDLOOP.

I noticed that you are doing a select inside loop into table 'it_sap_data', don't your internal table 'it_sap_data' is getting refreshed with new records everytime? This may be some other problem( i guess).

Regards,

Vivek

Read only

Former Member
0 Likes
1,298

Try:


CONCATENATE 'IEQ' st_cdhdr-objectid INTO so_lifnr.
APPEND so_lifnr.

Rob

Read only

Former Member
0 Likes
1,297

Rob,

your suggestion worked.

APPEND so_lifnr.

what does this statement do. do you have time to expain this?

Read only

0 Likes
1,297

The select statement works with the actual table (select-option). Without doing the append, the data stays in the work area and the table remains empty. Since the table is empty, all entries will be picked up. after the append, the table has data that can be used by the select.

Rob

Read only

Former Member
0 Likes
1,297

Rob,

Thanks for the explanation.

Tim

Read only

0 Likes
1,297

Glad to help.

I can't begin to count the number of times I've gotten into trouble by forgetting to do the append after moving the fields to the header.

Rob