Skip to Content
0
Former Member
Dec 16, 2006 at 10:30 AM

Problem in the report

43 Views

HI Friends,

Its very urgent, Iam not getting the two line items, in itvbfa table.

iam sending my code pls check this.for SALES_DOC & REF_DOC there is a problem i was changed the code but it is not working.

&----


*& Report /BAJAJ/WAR_DOC_FLOW *

*& *

&----


*& PROGRAM : TO WARRANTY PROCESS DOCUMENT FLOW. *

*& WRITTEN BY : Girish *

*& DATE : 20-MAR-2006. *

*& REQUESTED BY : SHARAD OZARDE *

*& *

*& *

&----


REPORT /bajaj/war_doc_flow NO STANDARD PAGE HEADING.

**----


  • TABLES

**----


TYPE-POOLS : slis.

TABLES : qmel,

ycstqmel,

vbak,

vbfa.

*----


  • data definition

*----


DATA : gt_fieldcat TYPE slis_t_fieldcat_alv,

g_repid LIKE sy-repid,

i_layout TYPE slis_layout_alv,

i_events TYPE slis_t_event,

shed TYPE slis_listheader,

ithed TYPE slis_t_listheader.

DATA : lvd1(2) TYPE c,

lvm1(2) TYPE c,

lvy1(4) TYPE c,

v_period(30) TYPE c.

DATA : date(8) TYPE c.

DATA : BEGIN OF itycstqmel OCCURS 0,

qmnum LIKE ycstqmel-qmnum,

END OF itycstqmel.

DATA : BEGIN OF itqmel OCCURS 0,

qmnum LIKE qmel-qmnum,

erdat LIKE qmel-erdat,

vbeln LIKE qmel-vbeln,

bstnk LIKE qmel-bstnk,

kunum LIKE qmel-kunum,

END OF itqmel.

DATA : BEGIN OF itvbak OCCURS 0,

vbeln LIKE vbak-vbeln,

erdat LIKE vbak-erdat,

qmnum LIKE ycstqmel-qmnum,

END OF itvbak.

DATA : BEGIN OF itvbfa OCCURS 0,

vbeln LIKE vbfa-vbeln,

vbelv LIKE vbfa-vbelv,

vbtyp_n LIKE vbfa-vbtyp_n,

END OF itvbfa.

DATA : BEGIN OF itvbfa1 OCCURS 0,

vbeln LIKE vbfa-vbeln,

vbelv LIKE vbfa-vbelv,

vbtyp_n LIKE vbfa-vbtyp_n,

erdat LIKE vbfa-erdat,

END OF itvbfa1.

DATA : BEGIN OF itycswtitl OCCURS 0,

kunnr LIKE ycswt_wr_title-kunnr,

lrrcptdt LIKE ycswt_wr_title-lrrcptdt,

cldocrcptdt LIKE ycswt_wr_title-cldocrcptdt,

mtrlrcptdt LIKE ycswt_wr_title-mtrlrcptdt,

datauploaddt LIKE ycswt_wr_title-datauploaddt,

END OF itycswtitl.

DATA : BEGIN OF itfinal OCCURS 0,

customer LIKE qmel-kunum,

cou_batch LIKE ycstqmel-coupon_batch,

po_num LIKE vbak-vbeln,

notific LIKE vbak-bstnk,

date LIKE vbak-erdat,

sales_ord LIKE vbak-vbeln,

s_date LIKE vbak-erdat,

ref_doc LIKE vbak-vbeln,

bill_doc LIKE vbfa-vbeln,

b_date LIKE vbak-erdat,

lrrcptdt LIKE ycswt_wr_title-lrrcptdt,

cldocrcptdt LIKE ycswt_wr_title-cldocrcptdt,

mtrlrcptdt LIKE ycswt_wr_title-mtrlrcptdt,

datauploaddt LIKE ycswt_wr_title-datauploaddt,

END OF itfinal.

**----


  • SELECTION SCREEN

**----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.

PARAMETER: p_dealer LIKE qmel-kunum OBLIGATORY,

p_batch LIKE ycstqmel-coupon_batch OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

**----


  • INITIALIZATION

**----


INITIALIZATION.

g_repid = sy-repid.

PERFORM fieldcat_init USING gt_fieldcat.

**----


  • START-OF-SELECTION

**----


START-OF-SELECTION.

PERFORM select_data.

PERFORM final_tab.

**----


  • END-OF-SELECTION

**----


END-OF-SELECTION.

PERFORM display_data.

&----


*& Form FIELDCAT_INIT

&----


  • Form to generate & append fieldcat

----


  • -->P_GT_FIELDCAT[]

----


FORM fieldcat_init USING rt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

ls_fieldcat-fieldname = 'CUSTOMER'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_s = 'CUSTOMER'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'COU_BATCH'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'COUPON_BATCH'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'LRRCPTDT'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_l = 'LR RECEIPT DATE'.

ls_fieldcat-outputlen = 18.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'CLDOCRCPTDT'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_l = 'CLAIM DOC RECD DT'.

ls_fieldcat-outputlen = 18.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'MTRLRCPTDT'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_l = 'MATERIAL RECD DT'.

ls_fieldcat-outputlen = 20.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'DATAUPLOADDT'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_l = 'DATA UPLOAD DATE'.

ls_fieldcat-outputlen = 18.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'NOTIFIC'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'NOTIFICATION'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'DATE'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'CREATED ON'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'SALES_ORD'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'SALES ORDER'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'S_DATE'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'CREATED ON'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'REF_DOC'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'REF. DOC'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'BILL_DOC'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'BILL DOC'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'B_DATE'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'CREATED ON'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = 'PO_NUM'.

ls_fieldcat-tabname = 'ITFINAL'.

ls_fieldcat-seltext_m = 'PO_NUMBER'.

ls_fieldcat-outputlen = 14.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ENDFORM. " FIELDCAT_INIT

&----


*& Form SELECT_DATA

&----


  • Form used to Select data into the internal tables

----


*

*

----


FORM select_data.

SELECT qmnum

FROM ycstqmel

INTO TABLE itycstqmel

WHERE coupon_batch = p_batch.

IF NOT itycstqmel[] IS INITIAL.

SELECT qmnum

erdat

vbeln

bstnk

kunum

FROM qmel

INTO TABLE itqmel

FOR ALL ENTRIES IN itycstqmel

WHERE kunum = p_dealer

AND qmnum = itycstqmel-qmnum

AND qmart = 'ZW'.

ENDIF.

IF NOT itqmel[] IS INITIAL.

SELECT vbeln

erdat

qmnum

FROM vbak

INTO TABLE itvbak

FOR ALL ENTRIES IN itqmel

WHERE qmnum = itqmel-qmnum

AND vbeln = itqmel-vbeln

AND auart = 'ZWRE'.

ENDIF.

IF NOT itvbak[] IS INITIAL.

SELECT vbeln

vbelv

vbtyp_n

FROM vbfa

INTO TABLE itvbfa

FOR ALL ENTRIES IN itvbak

WHERE vbelv = itvbak-vbeln

AND vbtyp_n = 'T'.

ENDIF.

IF NOT itvbfa[] IS INITIAL.

SELECT vbeln

vbelv

vbtyp_n

erdat

FROM vbfa

INTO TABLE itvbfa1

FOR ALL ENTRIES IN itvbfa

WHERE vbelv = itvbfa-vbeln

AND vbtyp_n = 'O'.

ENDIF.

SELECT kunnr

lrrcptdt

cldocrcptdt

mtrlrcptdt

datauploaddt

FROM ycswt_wr_title

INTO TABLE itycswtitl

WHERE kunnr = p_dealer

AND coupon_batch = p_batch.

ENDFORM. " select_data

&----


*& Form DISPLAY_DATA

&----


  • Generates ALV list using function module

----


*

*

----


FORM display_data.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_callback_top_of_page = 'TOP_OF_PAGE1'

it_fieldcat = gt_fieldcat

is_layout = i_layout

it_events = i_events[]

TABLES

t_outtab = itfinal

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

REFRESH itfinal.

CLEAR itfinal.

ENDFORM. " DISPLAY_DATA

&----


*& Form FINAL_TAB

&----


  • Creation of Final table for alv display

----


*

*

----


FORM final_tab.

LOOP AT itqmel WHERE kunum = p_dealer.

itfinal-customer = p_dealer.

itfinal-cou_batch = p_batch.

MOVE itqmel-bstnk TO itfinal-po_num.

MOVE itqmel-qmnum TO itfinal-notific.

MOVE itqmel-erdat TO itfinal-date.

READ TABLE itycswtitl WITH KEY kunnr = p_dealer.

IF sy-subrc = 0.

MOVE itycswtitl-lrrcptdt TO itfinal-lrrcptdt.

MOVE itycswtitl-cldocrcptdt TO itfinal-cldocrcptdt.

MOVE itycswtitl-mtrlrcptdt TO itfinal-mtrlrcptdt.

MOVE itycswtitl-datauploaddt TO itfinal-datauploaddt.

ENDIF.

READ TABLE itvbak WITH KEY qmnum = itqmel-qmnum.

IF sy-subrc = 0.

MOVE itvbak-vbeln TO itfinal-sales_ord.

MOVE itvbak-erdat TO itfinal-s_date.

ENDIF.

READ TABLE itvbfa WITH KEY vbelv = itvbak-vbeln.

*********code added by Girish on 16/12/06 FS_9999102866********

  • LOOP AT itvbfa WHERE vbelv = itvbfa-vbeln.

IF sy-subrc = 0.

MOVE itvbfa-vbeln TO itfinal-ref_doc.

READ TABLE itvbfa1 WITH KEY vbelv = itvbfa-vbeln.

IF sy-subrc = 0.

MOVE itvbfa1-vbeln TO itfinal-bill_doc.

MOVE itvbfa1-erdat TO itfinal-b_date.

  • ENDIF.

*********code added by Girish on 16/12/06 FS_9999102866********

  • LOOP AT itvbfa WHERE vbelv = itvbfa-vbeln.

  • IF sy-subrc = 0.

  • MOVE itvbfa-vbeln TO itfinal-ref_doc.

  • ENDIF.

  • ENDLOOP.

********************code ended**********************************

ENDIF.

ENDIF.

APPEND itfinal.

CLEAR itfinal.

ENDLOOP.

ENDFORM. " final_tab

&----


*& Form TOP_OF_PAGE1

&----


  • Top of page1 for Logo & text display.

----


*

*

----


FORM top_of_page1.

date = sy-datum.

MOVE date+0(4) TO lvy1.

MOVE date+4(2) TO lvm1.

MOVE date+6(2) TO lvd1.

shed-typ = 'H'.

shed-info = 'BAJAJ AUTO LTD., AKURDI'.

APPEND shed TO ithed.

CLEAR shed.

shed-typ = 'S'.

shed-info = 'WARRANTY PROCESS DOCUMENT FLOW' .

APPEND shed TO ithed.

CLEAR shed.

shed-typ = 'S'.

shed-info = 'WARRANTY'.

APPEND shed TO ithed.

CLEAR shed.

shed-typ = 'S'.

CONCATENATE 'Report Date : ' lvd1 ':' lvm1 ':' lvy1 INTO v_period.

shed-info = v_period.

APPEND shed TO ithed.

CLEAR shed.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = ithed

i_logo = 'BAJAJLOGO1'.

REFRESH ithed.

ENDFORM. "TOP_OF_PAGE1