Skip to Content
0
Former Member
May 18, 2008 at 05:12 AM

Problem in output

19 Views

&----


*& Report ZMM_MATL_DESC

*&

&----


*&

*&

&----


REPORT zmm_matl_desc

LINE-COUNT 40

LINE-SIZE 80

NO STANDARD PAGE HEADING.

***************************DATA DECLARATION**************************

TYPE-POOLS: slis.

TABLES: mseg, mkpf.

DATA: BEGIN OF t_mseg OCCURS 0,

mblnr LIKE mseg-mblnr,

mjahr LIKE mseg-mjahr,

zeile LIKE mseg-zeile,

matnr LIKE mseg-matnr,

lsmng LIKE mseg-lsmng,

menge LIKE mseg-menge,

ebeln LIKE mseg-ebeln,

werks LIKE mseg-werks,

ebelp LIKE mseg-ebelp,

budat LIKE mkpf-budat,

shortage type f,

delflag TYPE c,

END OF t_mseg.

DATA: l_mseg LIKE t_mseg OCCURS 0.

DATA: BEGIN OF t_mkpf OCCURS 0,

mblnr LIKE mkpf-mblnr,

mjahr LIKE mkpf-mjahr,

budat LIKE mkpf-budat,

END OF t_mkpf.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

loc_cnt TYPE i.

DATA: l_tabix TYPE sytabix.

DATA: BEGIN OF t_ekko OCCURS 0,

ebeln LIKE ekko-ebeln,

bsart LIKE ekko-bsart,

END OF t_ekko.

DATA: BEGIN OF t_ekpo OCCURS 0,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebeln,

konnr LIKE ekpo-konnr,

END OF t_ekpo.

**************************SELECTION SCREEN***************************

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

SELECT-OPTIONS: s_plant FOR t_mseg-werks OBLIGATORY,

s_matnr FOR t_mseg-matnr,

s_datum FOR t_mseg-budat .

SELECTION-SCREEN: END OF BLOCK b1.

START-OF-SELECTION.

PERFORM sub_selection.

PERFORM sub_getdata.

PERFORM sub_updt_ebeln.

END-OF-SELECTION.

CONSTANTS CTNM(6) TYPE C VALUE 't_mseg'.

PERFORM sub_write USING:

  • COL_POS FIELDNM TABNAME SEL-TEXT DO-SUM NO-ZERO

***********************************************************************

' ' loc_cnt 'MBLNR' CTNM text-011 space space ' ',

' ' loc_cnt 'ZEILE' CTNM text-012 space space ' ',

' ' loc_cnt 'BUDAT' CTNM text-013 space space ' ',

' ' loc_cnt 'MATNR' CTNM text-014 space space ' ',

' ' loc_cnt 'LSMNG' CTNM text-015 space space ' ',

' ' loc_cnt 'MENGE' CTNM text-016 space space ' ',

' ' loc_cnt 'shortage' CTNM TEXT-017 space space ' ',

' ' loc_cnt 'EBELN' CTNM text-018 space space ' '.

PERFORM sub_print_data.

&----


*& Form SUB_WRITE

&----


  • text

----


  • -->: text

  • -->P_CHECK text

  • -->P_CNT text

  • -->P_FIELD_NAME text

  • -->P_TAB_NAME text

  • -->P_SEL_TEXT text

  • -->P_DO_SUM text

  • -->P_NO_ZERO text

  • -->P_INPUT text

----


FORM sub_write USING:

p_check TYPE any

p_cnt TYPE any

p_field_name TYPE any

p_tab_name TYPE any

p_sel_text TYPE any

p_do_sum TYPE any

p_no_zero TYPE any

p_input TYPE any.

CLEAR: wa_fieldcat.

P_CNT = P_CNT + 1.

wa_fieldcat-col_pos = p_cnt.

wa_fieldcat-fieldname = p_field_name.

wa_fieldcat-tabname = p_tab_name .

wa_fieldcat-seltext_l = p_sel_text.

wa_fieldcat-do_sum = p_do_sum .

wa_fieldcat-no_zero = p_no_zero.

wa_fieldcat-input = p_input.

wa_fieldcat-checkbox = p_check.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

ENDFORM. "SUB_WRITE

&----


*& Form SUB_SELECTION

&----


  • selection from screen & condition checking *

----


FORM sub_selection.

SELECT mblnr mjahr zeile matnr lsmng menge ebeln ebelp

INTO CORRESPONDING FIELDS OF TABLE t_mseg

FROM mseg

WHERE ( bwart = '105' ) OR ( bwart = '101' )

AND werks IN s_plant

AND matnr IN s_matnr.

IF NOT s_datum[] IS INITIAL.

SELECT mblnr mjahr budat

FROM mkpf

INTO TABLE t_mkpf

WHERE budat IN s_datum.

ENDIF.

IF NOT t_mkpf[] IS INITIAL.

LOOP AT t_mseg.

CLEAR l_tabix.

l_tabix = sy-tabix.

CLEAR t_mkpf.

READ TABLE t_mkpf WITH KEY mblnr = t_mseg-mblnr

mjahr = t_mseg-mjahr.

IF sy-subrc <> 0.

CLEAR t_mseg-delflag.

t_mseg-delflag = 'X'.

MODIFY t_mseg INDEX l_tabix.

CLEAR t_mseg.

Else.

t_mseg-budat = t_mkpf-budat.

MODIFY t_mseg INDEX l_tabix.

CLEAR t_mseg.

ENDIF.

ENDLOOP.

DELETE t_mseg WHERE delflag = 'X'.

ENDIF.

ENDFORM. "SUB_SELECTION

&----


*& Form SUB_GETDATA

&----


  • obtain values from database

----


FORM sub_getdata.

l_mseg[] = t_mseg[].

IF NOT l_mseg IS INITIAL.

SORT l_mseg BY ebeln ebelp.

DELETE ADJACENT DUPLICATES FROM l_mseg COMPARING ebeln ebelp.

ENDIF.

IF NOT l_mseg[] IS INITIAL.

SELECT ebeln ebelp konnr

INTO TABLE t_ekpo

FROM ekpo

FOR ALL ENTRIES IN l_mseg

WHERE ebeln = l_mseg-ebeln.

ENDIF.

IF NOT l_mseg IS INITIAL.

SORT l_mseg BY ebeln.

DELETE ADJACENT DUPLICATES FROM l_mseg COMPARING ebeln.

ENDIF.

IF NOT l_mseg[] IS INITIAL.

SELECT ebeln bsart

INTO TABLE t_ekko

FROM ekko

FOR ALL ENTRIES IN l_mseg

WHERE ebeln = l_mseg-ebeln.

ENDIF.

ENDFORM. "SUB_GETDATA

&----


&

& Form SUB_PRINT_DATA &

&----


&

& Print Data &

&----


&

FORM sub_print_data .

IF NOT t_mseg[] IS INITIAL.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = it_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = t_mseg

  • 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.

CLEAR: wa_fieldcat.

ELSE.

MESSAGE text-019 TYPE 'S'.

ENDIF.

ENDFORM. " SUB_PRINT_DATA

&----


&

& Form sub_updt_ebeln &

&----


&

& Update PO data &

&----


&

FORM sub_updt_ebeln .

DATA: l_tabix type sytabix.

CLEAR t_mseg.

LOOP AT t_mseg.

clear l_tabix.

l_tabix = sy-tabix.

CLEAR t_ekko.

READ TABLE t_ekko WITH KEY ebeln = t_mseg-ebeln

bsart = 'ZDS'.

IF sy-subrc = 0.

clear t_ekpo.

READ TABLE t_ekpo WITH KEY ebeln = t_mseg-ebeln

ebelp = t_mseg-ebelp.

IF sy-subrc <> 0.

t_mseg-ebeln = t_ekpo-konnr.

Endif.

Endif.

t_mseg-shortage = t_mseg-lsmng - t_mseg-menge.

MODIFY t_mseg index l_tabix.

clear t_mseg.

ENDLOOP.

ENDFORM. " sub_updt_ebeln

My program is runing succesfully... Only problem is that when the user is not selecting date is the selection screen the posting date is not also appearing in the output.

I know that the budat field is not updated in t_mseg table...

Can any body help to work it out?

regards

Sobhan