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

check my logic

Hi abaper's

i am applying following logic in one of my program actually i need all three fields BUdat, HKONT and MATNR in my itab2. In my itab2 matnr field is showing no data ...its coming empty.

Logic is :

types: BEGIN OF ty_itab1,

BUDAT LIKE BSIs-BUDAT,

hkont like bsis-hkont,

MATNR LIKE mseg-MATNR,

END OF ty_ITAB1.

*31.01.08

data : itab1 type table of ty_itab1 with header line.

data : wa1 type ty_itab1.

data : itab2 type table of ty_itab1 with header line.

SELECT budat hkont FROM BSIs INTO CORRESPONDING FIELDS OF TABLE ITAB1 WHERE BUDAT IN DATUM AND hkont in hkont.

loop at itab1 into wa1.

select single matnr into wa1-matnr from mseg where sakto = wa1-hkont and matnr <>' '.

move wa1 to itab2.

append itab2.

endloop.

Any suggestions from abaper's will be appreciated.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 06:46 AM

    in place of Loop use innner join / for all entries

    inner join code :

    types: BEGIN OF ty_itab1,

    BUDAT LIKE BSIs-BUDAT,

    hkont like bsis-hkont,

    MATNR LIKE mseg-MATNR,

    END OF ty_ITAB1.

    *31.01.08

    data : itab1 type table of ty_itab1 with header line.

    data : wa1 type ty_itab1.

    data : itab2 type table of ty_itab1 with header line.

    SELECT abudat ahkont b~matnr

    INTO TABLE ITAB1

    FROM BSIs as a innerjoin mseg as b

    on ahkont = bsakto

    WHERE a~BUDAT IN DATUM AND

    a~hkont in hkont and

    b~matnr ne ' '.

    try with this

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 06:49 AM

    select single matnr into wa1-matnr from mseg where sakto = wa1-hkont and matnr ' '.

    I am not getting what u r doing in the above select statement by giving matnr ' '.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 06:51 AM

    matnr is coming empty because of the following condition in ur code.

    select single matnr into wa1-matnr from mseg where sakto = wa1-hkont and matnr ' '.
    

    You are selecting only those records for which matnr is empty.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 06:53 AM

    >select single matnr into wa1-matnr from mseg where sakto = wa1-hkont and matnr ' '.

    1. You shld get syntax error as there is no relational operator between MATNR and ' '.

    2. Retreiving data from BSEG with HKONT as selection can cause performance issue. Try mapping BSIS to BSEG with BUKRS, BELNR, GJAHR & HKONT and MATNR.

    Regar

    Eswar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 07:16 AM

    hi all

    thanks for your prompt reply..now i am getting matnr in my same code i havent changed anything except removed matnr ne ' '.

    while debbuging i checked that my matnr field is picking wrong entry which is not satisfying this select query conditions

    what can be the reason?

    Add a comment
    10|10000 characters needed characters exceeded

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.