Skip to Content
-3

I wish to display data from KNA1 and KNB1 using 3 parameters..Need help Thanking you in advance.>!!

Jun 11, 2017 at 01:11 PM

134

avatar image
Former Member

*&---------------------------------------------------------------------*
*& Report ZCS_REG
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zcs_reg.
TABLES : kna1, knb1, bkpf.

TYPES: BEGIN OF ty_knb1,
bukrs TYPE knb1-bukrs,
kunnr TYPE knb1-kunnr,
akont TYPE knb1-akont,
END OF ty_knb1.

TYPES: BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
land1 TYPE kna1-land1,
pstlz TYPE kna1-pstlz,
END OF ty_kna1.

TYPES: BEGIN OF ty_bkpf,
bukrs TYPE bkpf-bukrs,
gjahr TYPE bkpf-gjahr,
END OF ty_bkpf.

TYPES: BEGIN OF ty_final,
bukrs TYPE knb1-bukrs,
kunnr TYPE knb1-kunnr,
akont TYPE knb1-akont,
name1 TYPE kna1-name1,
land1 TYPE kna1-land1,
pstlz TYPE kna1-pstlz,
gjahr TYPE bkpf-gjahr,
END OF ty_final.

DATA: it_kna1 TYPE TABLE OF ty_kna1,
wa_kna1 TYPE ty_kna1.

DATA: it_knb1 TYPE TABLE OF ty_knb1,
wa_knb1 TYPE ty_knb1.
DATA: it_bkpf TYPE TABLE OF ty_bkpf,
wa_bkpf TYPE ty_bkpf.

DATA: it_final TYPE TABLE OF ty_final,
wa_final TYPE ty_final.

SELECTION-SCREEN: BEGIN OF BLOCK a WITH FRAME TITLE text-001.

SELECT-OPTIONS : p_bukrs FOR bkpf-bukrs,
p_kunnr FOR knb1-kunnr,
p_gjahr FOR bkpf-gjahr.

* PARAMETERS: P_BUKRS TYPE BKPF-BUKRS,
* P_KUNNR TYPE KNB1-KUNNR,
* P_GJAHR TYPE BKPF-GJAHR.

SELECTION-SCREEN END OF BLOCK a.

*START-OF-SELECTION.

SELECT bukrs
gjahr FROM bkpf INTO TABLE it_bkpf WHERE bukrs IN p_bukrs AND gjahr IN p_gjahr.

SELECT name1 land1 pstlz kunnr
FROM kna1 INTO TABLE it_kna1
WHERE kunnr = kna1-kunnr.
*
*SELECT KUNNR
* AKONT
* BUKRS
* FROM KNB1 INTO TABLE IT_KNB1
* FOR ALL ENTRIES IN IT_KNB1
* WHERE KUNNR = IT_KNB1-KUNNR.
*
*SELECT BUKRS
* GJAHR
* FROM BKPF INTO TABLE IT_BKPF
* FOR ALL ENTRIES IN IT_BKPF
* WHERE BUKRS = IT_BKPF-BUKRS.


* SELECT kunnr vtweg kunn2 defpa FROM knvp INTO TABLE it_knvp FOR ALL ENTRIES IN it_knvv
* WHERE vtweg = it_knvv-vtweg.

*END-OF-SELECTION.


LOOP AT it_kna1 INTO wa_kna1.

wa_final-name1 = wa_kna1-name1.
wa_final-land1 = wa_kna1-land1.
wa_final-pstlz = wa_kna1-pstlz.

READ TABLE it_knb1 INTO wa_knb1 WITH KEY kunnr = wa_kna1-kunnr.

wa_final-kunnr = wa_knb1-kunnr.
wa_final-akont = wa_knb1-akont.

ENDLOOP.





WRITE: /
sy-vline,
10 'CUSTOMER NAME',
sy-vline,
20 'COUNTRY',
sy-vline,
40 'POSTAL CODE',
sy-vline,
60 'Customer Account No.',
sy-vline,
80 'Recon Account No.'.


LOOP AT it_final INTO wa_final.

WRITE: /
sy-vline,
10 wa_final-name1,
sy-vline,
20 wa_final-land1,
sy-vline,
40 wa_final-pstlz,
sy-vline,
60 wa_final-kunnr,
sy-vline,
80 wa_final-akont,
sy-vline.

ENDLOOP.

10 |10000 characters needed characters left characters exceeded

Please use code formatting when posting code, it makes it much easier to read.

0
Former Member
Mike Pokraka

Done that now.. please help me in this. thank you

0

No you haven't. To apply code format, select the code and click the formatting button labeled "CODE".

I am not sure what the issue is, you've just pasted a bunch of difficult to read code (and largely commented out) with little explanation. Please describe the problem you are facing. What are you expecting and what is not working? What have you tried?

More people might try to help if a question is easy to understand.

1
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Horst Keller
Jun 12, 2017 at 09:16 AM
0

First of all, don't use obsolete syntax as TABLES and short forms in Open SQL ...

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Can you please elaborate where exactly I am using the short form in Open SQL and what is the substitute for the key word TABLES.??

0
0
Rob Dielemans Jun 13, 2017 at 01:47 PM
0

Why do you need to create an ABAP program for this requirement?

It can be fulfilled using SE16H and a join. If you don't have se16H, then SQVI should be a quick and easy way to display data between 3 tables.

Kind regards, Rob Dielemans

Share
10 |10000 characters needed characters left characters exceeded