cancel
Showing results for 
Search instead for 
Did you mean: 

why isnt this query working ?

Former Member
0 Kudos
129

Hello,

I have an table of line type


TYPES:
    BEGIN OF t_repdata,
      belnr   TYPE  belnr_d,        " Document No.
      lifnr   TYPE  wt_acno,        " Vendor No.
      lfnam   TYPE  lfa1-name1,     " Vendor Name
      lifntn  TYPE  stcd1,          " NTN
      lifnic  TYPE  stcd2,          " CNIC
      lifreg  TYPE  stcd1,          " Reg No.
      nature  TYPE  text40,         " Nature of Payment
      section TYPE  txt40,          " Section under whicn Tax deducted/collected
      bldat   TYPE  bldat,          " Date of Payment
      bsamt   TYPE  wt_bs1,         " WHT Base Amount
      reason  TYPE  text30,         " Reason for exemption
    END OF t_repdata.

am joining 3 tables and retrieving data,


SELECT bk~belnr wt~wt_acco lf~name1 lf~stcd1 lf~stcd2 lf~stcd1 bk~bldat wt~wt_qsshb
    INTO CORRESPONDING FIELDS OF TABLE gt_repdata FROM bkpf AS bk
      JOIN with_item AS wt ON ( wt~bukrs = bk~bukrs AND
                                wt~belnr = bk~belnr AND
                                wt~gjahr = bk~gjahr )

      JOIN lfa1 AS lf ON ( lf~lifnr = wt~wt_acco )

      WHERE bk~bukrs EQ p_bukrs AND
            bk~gjahr EQ p_gjahr AND
          ( bk~blart EQ 'KZ' OR bk~blart EQ 'ZP' ) AND
            bk~bldat IN s_bldat AND
            wt~wt_qbshb EQ 0 AND
            wt~wt_acco IN s_lifnr.

This query is only getting the belnr and bldat from bkpf , showing no data from WITH_ITEM or LFA1 in the table... wat is wrong with this query ?

Thanks and appreciated.

Shehryar Dahar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

BEGIN OF t_repdata,

belnr TYPE belnr_d, " Document No.

wt_acno TYPE WT_ACNO, " Vendor No.

name1 TYPE lfa1-name1, " Vendor Name

stcd1 TYPE stcd1, " NTN

stcd2 TYPE stcd2, " CNIC

lifreg TYPE stcd1, " Reg No.

nature TYPE text40, " Nature of Payment

section TYPE txt40, " Section under whicn Tax deducted/collected

bldat TYPE bldat, " Date of Payment

bsamt TYPE wt_bs1, " WHT Base Amount

reason TYPE text30, " Reason for exemption

END OF t_repdata.

Basically the name of the fields in the internal table u defined should be the same name as the name in the database table . when u use move corresponding it checks for the same name and move the values . so it is necessary to have the same name in the internal table. please change the names in youur internal table as specified above .hope this helps u .

Answers (3)

Answers (3)

Former Member
0 Kudos

Points given for helpful answers. I used INTO TABLE instead. Thanks everyone..!

Clemenss
Active Contributor
0 Kudos

Hi shehryar,

to match the corresponding fields you have to give alias names for the fields retrieved:

[possibly incomplete9


SELECT bk~belnr wt~wt_acco <b>as lifnr </b> lf~name1 <b>as lfnam</b> lf~stcd1 lf~stcd2 lf~stcd1 bk~bldat wt~wt_qsshb

Regards,

Clemens

Former Member
0 Kudos

Hi shehryar,

In your types declaration please change the field names as those in WITH_ITEM and LFA1 table . For example lfnam from LFA1 in the types declration should be renamed "NAME1" . Note that without this even your "INTO CORRESPONDING FIELDS " clause in the query will fail. This clause checks by field names and not by domain level .So even tho the domains u ve specified are correct the fields are not getting populated

REWARD if helpful