Skip to Content
0
Former Member
Dec 21, 2006 at 09:14 AM

Remove inside loop , select.....end select

272 Views

Hi experts in following code remove select... end select and remove select inside loop, reply me soon here 'T_' refers to internal tables

LOOP AT T_IAUG.

MOVE T_ICOLDATA-GJAHR TO T_ICOLDATA-XGJHR.

SELECT * FROM BSAK INTO TABLE T_IBSAK

WHERE BUKRS = T_IAUG-BUKRS

AND AUGDT = T_IAUG-AUGDT

AND AUGBL = T_IAUG-AUGBL.

LOOP AT T_IBSAK.

CLEAR: T_ICOLDATA, D_DATAD, D_DATAK.

SELECT * FROM BSEG WHERE BUKRS = T_IBSAK-BUKRS

AND BELNR = T_IBSAK-BELNR

AND GJAHR = T_IBSAK-GJAHR.

IF T_ICOLDATA-LIFNR IS INITIAL.

MOVE BSEG-LIFNR TO T_ICOLDATA-LIFNR.

ENDIF.

CASE BSEG-HKONT.

WHEN '0005700022'. " NSL

IF BSEG-SHKZG = 'S'.

T_ICOLDATA-NSLBT = T_ICOLDATA-NSLBT + BSEG-DMBTR.

ELSE.

T_ICOLDATA-NSLBT = T_ICOLDATA-NSLBT - BSEG-DMBTR.

ENDIF.

WHEN '0005700025'. " GST

IF BSEG-SHKZG = 'S'.

T_ICOLDATA-GSTBT = T_ICOLDATA-GSTBT + BSEG-DMBTR.

ELSE.

T_ICOLDATA-GSTBT = T_ICOLDATA-GSTBT - BSEG-DMBTR.

ENDIF.

ENDCASE.

IF ( NOT BSEG-KUNNR IS INITIAL OR NOT BSEG-LIFNR IS INITIAL ).

  • if bseg-shkzg = 'S'.

D_DATAD = D_DATAD + BSEG-DMBTR.

  • else.

  • d_datak = d_datak - bseg-dmbtr.

ENDIF.

  • endcase.

ENDSELECT.

IF NOT ( T_ICOLDATA-NSLBT IS INITIAL

AND T_ICOLDATA-GSTBT IS INITIAL ).

IF T_ICOLDATA-NSLBT LT 0 OR T_ICOLDATA-GSTBT LT 0.

T_ICOLDATA-INVBT = D_DATAD * -1.

ELSE.

T_ICOLDATA-INVBT = D_DATAD.

ENDIF.

SELECT SINGLE * FROM BKPF WHERE BUKRS = T_IBSAK-BUKRS

AND BELNR = T_IBSAK-BELNR

AND GJAHR = T_IBSAK-GJAHR.

MOVE BKPF-XBLNR TO T_ICOLDATA-XBLNR.

MOVE BKPF-BUDAT TO T_ICOLDATA-BUDAT.

MOVE BKPF-BELNR TO T_ICOLDATA-BELNR.

MOVE T_IAUG-AUGDT TO T_ICOLDATA-AUGDT.

MOVE T_IAUG-AUGBL TO T_ICOLDATA-AUGBL.

APPEND T_ICOLDATA.

ENDIF.

ENDLOOP.

ENDLOOP.