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

check reversal

Former Member
0 Likes
878

Hi experts,

Iam trying to get the details form MKPF & MSEG and passing into T_INS internal table.Here i dont want to get the documents which are reversed(SMBLN).How can i do that?

What is the better approach?


      SELECT * INTO TABLE T_MKPF FROM MKPF
            WHERE  VGART EQ 'WF' AND
                   XBLNR = P_XBLNM.

      SELECT * INTO TABLE T_MSEG FROM MSEG
              FOR ALL ENTRIES IN T_MKPF
               WHERE MBLNR = T_MKPF-MBLNR
                 AND MJAHR = T_MKPF-MJAHR
                 AND BWART = '101'
                 AND INSMK = 'X'.



      LOOP AT T_MSEG.
        MOVE-CORRESPONDING T_MSEG TO T_INS.
        APPEND T_INS.
        CLEAR T_INS.
      ENDLOOP.

Hi experts,

Iam trying to get the details form MKPF & MSEG and passing into T_INS internal table.Here i dont want to get the documents which are reversed(SMBLN).How can i do that?

What is the better approach?


      SELECT * INTO TABLE T_MKPF FROM MKPF
            WHERE  VGART EQ 'WF' AND
                   XBLNR = P_XBLNM.

      SELECT * INTO TABLE T_MSEG FROM MSEG
              FOR ALL ENTRIES IN T_MKPF
               WHERE MBLNR = T_MKPF-MBLNR
                 AND MJAHR = T_MKPF-MJAHR
                 AND BWART = '101'
                 AND INSMK = 'X'.



      LOOP AT T_MSEG.
        MOVE-CORRESPONDING T_MSEG TO T_INS.
        APPEND T_INS.
        CLEAR T_INS.
      ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
830

Hi

SELECT * INTO TABLE T_MKPF FROM MKPF

WHERE VGART EQ 'WF' AND

XBLNR = P_XBLNM.

SELECT * INTO TABLE T_MSEG FROM MSEG

WHERE AND BWART = '101'

AND INSMK = 'X'.

sort t_mseg by mblnr mjahr

loop at t_mkpf.

clear t_mseg.

read table t_mseg with key MBLNR = T_MKPF-MBLNR

MJAHR = T_MKPF-MJAHR

SMBLN NE SPACE

Binary search.

MOVE-CORRESPONDING T_MSEG TO T_INS

APPEND T_INS.

CLEAR T_INS.

endloop

Message was edited by: Harikishore Sreenivasulu

Read only

0 Likes
830

Hi Kaki,

      SELECT * 
         INTO TABLE T_MKPF
          FROM MKPF  
          WHERE  VGART EQ 'WF'
 AND     XBLNR = P_XBLNM. 
<b>if sy-subrc = 0.</b>
     SELECT * 
INTO TABLE T_MSEG
 FROM MSEG    
FOR ALL ENTRIES IN T_MKPF 
  WHERE MBLNR = T_MKPF-MBLNR
    AND MJAHR = T_MKPF-MJAHR  
     AND BWART = '101' 
     AND INSMK = 'X'. 
  LOOP AT T_MSEG.
    MOVE-CORRESPONDING T_MSEG TO T_INS.
    APPEND T_INS. 
    CLEAR T_INS. 
  ENDLOOP.
<b>ENDIF</b>.

it's fine , is there any specific problem..

Read only

Former Member
0 Likes
830

hI,

Check FOR smbln NE space.

For Ex.

SELECT * INTO TABLE T_MSEG FROM MSEG

FOR ALL ENTRIES IN T_MKPF

WHERE MBLNR = T_MKPF-MBLNR

AND MJAHR = T_MKPF-MJAHR

AND BWART = '101'

AND INSMK = 'X'

and smbln ne space.

Read only

lajitha_menon
Contributor
0 Likes
830

Hi, please try this..

SELECT * INTO TABLE T_INS

from MSEG as a

inner join mkpf as b

on amblnr = bmblnr

and amjahr = bmjahr

WHERE VGART EQ 'WF' AND

XBLNR = P_XBLNM

AND BWART = '101'

AND INSMK = 'X'.

Table T_INS should have same row sequence as in mseg . Or else, you have to specify fields in particular instead of the whole table. Performance-wise, that will be faster.

cheers

Read only

Former Member
0 Likes
830

You can incorporate the last loop

LOOP AT T_MSEG.

MOVE-CORRESPONDING T_MSEG TO T_INS.

APPEND T_INS.

CLEAR T_INS.

ENDLOOP.

into the second select statement by using INTO CORRESPONDING FIELDS OF.

This way u will not require the tmp table T_MSEG and will also save the looping time for T_MSEG table.

regards,

Sumeet Mishra