Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

its very urgent plz help me

this is my program

TABLES: VBRK, VBRP, KNA1.

DATA: BEGIN OF ITAB OCCURS 0,

WERKS LIKE VBRP-WERKS, " PLANT CODE

SPART LIKE VBRK-SPART, " DIVISION

MATNR LIKE VBRP-MATNR, " MATERIAL CODE

VBELN LIKE VBRK-VBELN, " EXC. INVOICE NO

ARKTX LIKE VBRP-ARKTX, " MATERIAL DESCRIPTION

NETWR LIKE VBRP-NETWR, " BASIC PRICE

VTWEG LIKE VBRK-VTWEG, " DISTIBUTION CHANNEL

KUNAG LIKE VBRK-KUNAG, " CUSTOMER CODE

FKDAT LIKE VBRK-FKDAT, " PERIOD

SFAKN LIKE VBRK-SFAKN, " CANCELLED INVOICE

FKIMG LIKE VBRP-FKIMG, " INVOICE QTY

NAME1 LIKE KNA1-NAME1, " CUSTOMER NAME

KUNNR LIKE KNA1-KUNNR, " CUSTOMER CODE

END OF ITAB.

DATA: BEGIN OF ITAB1 OCCURS 0,

NAME1 LIKE KNA1-NAME1,

KUNNR LIKE KNA1-KUNNR,

KUNAG LIKE VBRK-KUNAG,

END OF ITAB1.

SELECT-OPTIONS PLT_CODE FOR VBRP-WERKS.

SELECT-OPTIONS DST_CH FOR VBRK-VTWEG.

SELECT-OPTIONS DIVISION FOR VBRP-SPART.

SELECT-OPTIONS CUST_COD FOR VBRK-KUNAG.

SELECT-OPTIONS PERIOD FOR VBRK-FKDAT.

SELECT-OPTIONS MAT_CODE FOR VBRP-MATNR.

SELECT BPWERKS BKSPART BPMATNR BKVBELN BPARKTX BPNETWR

BKVTWEG BKKUNAG BKFKDAT BKFKSTO BP~FKIMG

INTO CORRESPONDING FIELDS OF ITAB

FROM VBRP AS BP

INNER JOIN VBRK AS BK ON BKVBELN = BPVBELN

WHERE

BP~WERKS IN PLT_CODE AND

BK~VTWEG IN DST_CH AND

BK~SPART IN DIVISION AND

BK~KUNAG IN CUST_COD AND

BP~MATNR IN MAT_CODE AND

BK~FKDAT IN PERIOD .

SELECT NAME1 KUNNR FROM KNA1

INTO TABLE ITAB1

WHERE

KUNNR = ITAB-KUNAG.

READ TABLE ITAB1 WITH KEY KUNNR = ITAB-KUNNR.

IF SY-SUBRC = 0.

ITAB-NAME1 = ITAB1-NAME1.

ITAB-KUNNR = ITAB1-KUNNR.

ENDIF.

APPEND ITAB.

ENDSELECT.

CLEAR : ITAB.

LOOP AT ITAB.

WRITE: / ITAB-NAME1,ITAB-KUNAG.

inthis program i want to collect the data of name1 from table kna1 into my main itab but the data of name1 reach to header of itab not in it.

so plz help me plz plz plz

Tags:
Former Member
replied

Hi Krishna..

Don't Use SELECT.. ENDSELECT . It will be very inefficient.

Try this way...

SELECT BPWERKS BKSPART BPMATNR BKVBELN BPARKTX BPNETWR

BKVTWEG BKKUNAG BKFKDAT BKFKSTO BP~FKIMG

<b>INTO CORRESPONDING FIELDS OF TABLE ITAB</b>

FROM VBRP AS BP

INNER JOIN VBRK AS BK ON BKVBELN = BPVBELN

WHERE

BP~WERKS IN PLT_CODE AND

BK~VTWEG IN DST_CH AND

BK~SPART IN DIVISION AND

BK~KUNAG IN CUST_COD AND

BP~MATNR IN MAT_CODE AND

BK~FKDAT IN PERIOD .

Loop at ITAB.

<b>SELECT SINGLE NAME1 KUNNR FROM KNA1

INTO (ITAB-NAME1, ITAB-KUNNR)

WHERE

KUNNR = ITAB-KUNAG.

</b>

IF SY-SUBRC = 0.

<b>MODIFY ITAB TRANSPORTING NAME1 KUNNR.</b>

ENDIF.

ENDLOOP.

CLEAR : ITAB.

Now check the data in ITAB.

<b>REWARD IF HELPFUL.</b>

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question