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

Link between tables

Former Member
0 Likes
675

i have to replace posting number with belnr of bseg table in the out put

SELECT posting_number posting_date  position_text SUM( p_net_amount ) AS p_net_amount INTO
   CORRESPONDING FIELDS OF TABLE  t_rcpt
   FROM tcj_positions   WHERE
   kdauf IN s_vbeln "  ORDER NO USED  IN FBCJ
   AND
   transact_number  EQ 5
   GROUP BY posting_number posting_date position_text.

   LOOP AT   t_rcpt.
     t_rcpt-des = 'CASH'.
     t_rcpt-posting_number =   t_rcpt-belnr.
     t_rcpt-sgtxt = t_rcpt-position_text. " edit by khurram 12/14/2015
     MODIFY  t_rcpt.

can any one help

2 REPLIES 2
Read only

former_member183045
Contributor
0 Likes
572

I am not sure if I understand your question right, but let it give a try.

The value of tcj_positions-posting_number correspondents to the value bseg-belnr.

Thus, to get the desired value into your table t_rcpt the following modification on your select should give you the desired value.

SELECT posting_number AS belnr posting_date pos....

Hope it helps,

Andreas

Read only

former_member184158
Active Contributor
0 Likes
572

Hello Khuram,

I think you have to join between the tables BSEG and tcj_positions.

could you try this code, may it help you, and just check the values if they are correct, or as you expecte.

REPORT zibo_pg_select.

DATA t_rcpt TYPE TABLE OF tcj_positions.
DATA lt_bseg TYPE TABLE OF bseg.
FIELD-SYMBOLS <ls_rcpt> TYPE tcj_positions.

DATA ls_bseg TYPE bseg.

SELECT posting_number posting_date  position_text SUM( p_net_amount ) AS p_net_amount INTO
   CORRESPONDING
FIELDS OF TABLE  t_rcpt
  
FROM tcj_positions   WHERE
   kdauf
IN s_vbeln "  ORDER NO USED  IN FBCJ
  
AND
   transact_number 
EQ 5
  
GROUP BY posting_number posting_date position_text.

SELECT * FROM bseg AS bseg
 
INTO TABLE lt_bseg
 
FOR ALL ENTRIES IN t_rcpt
 
WHERE bseg~bukrs = t_rcpt-comp_code
AND bseg~belnr = t_rcpt-posting_number
AND bseg~buzei = t_rcpt-position_number.


LOOP AT t_rcpt ASSIGNING <ls_rcpt>.
 
READ TABLE lt_bseg INTO ls_bseg
 
WITH KEY
   bukrs
= <ls_rcpt>-comp_code
  belnr
= <ls_rcpt>-posting_number
  buzei
= <ls_rcpt>-position_number.

 
IF sy-subrc = 0.
    <ls_rcpt>
-posting_number ls_bseg-belnr.
 
ELSE.
   
CONTINUE.
 
ENDIF.


ENDLOOP.



regards

Ebrahim