Application Development 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: 

data is not populating into internal table only one field others fieldsok

Former Member
0 Kudos

Please I am facing a problem I am populatinf the fields to internal table Iam getting all the fields but only one field "QTYDIFF" i am not getting into my internal table here i am presenting the whole code please help me.

by ASHOK

REPORT ZASH_ALV_TEST1 no standard page heading

TYPE-POOLS : slis.

tables: ekbe, " P.O. line history

ekpo, " P.O. line

ekko, " P.O. header

eord, " Purchasing Source List

lfa1, " Vendor Master

marc, " Plant Data for Material

t024.

*DATA : lt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA : l1t_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ws_title TYPE lvc_title VALUE 'The TORO Company'.

DATA: report_id LIKE sy-repid.

DATA : l_f_layout TYPE slis_layout_alv.

----


  • Work fields

----


data: w_po_price type p decimals 5,

w_diff_qty type p decimals 3,

w_diff_value type p decimals 2,

w_hist-qtyinvd type p decimals 3,

w_hist-valdif1 type p decimals 2,

w_hist-qtydiff type p decimals 3,

w_diff_amount type p decimals 2, "WkReq #8526

w_hist-valdiff(12) type p decimals 2. "WkReq #8526

----


  • Internal Tables

----


data: begin of x_hist,

lifnr like ekko-lifnr,

name1 like lfa1-name1,

aedat like ekko-aedat, "Source List Create Date

ekgrp like ekko-ekgrp,

ebeln like ekko-ebeln,

EKORG LIKE EKKO-EKORG,

eknam like t024-eknam,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

netpr like ekpo-netpr,

peinh like ekpo-peinh,

matkl like ekpo-matkl,

werks like ekpo-werks,

lastact like ekbe-budat, "Last Activity Date

qtyrcvd like ekbe-menge,

qtyinvd like ekbe-menge,

amtrcvd like ekbe-dmbtr, "WkReq #8526

amtinvd like ekbe-dmbtr, "WkReq #8526

valdiff like ekpo-netpr,

absdiff like ekpo-netpr,

qtydiff like ekbe-menge,

vdatu(08) type c, "Source List Valid From

bdatu(10) type c, "Source List Validto Dte

elikz like ekpo-elikz, "Delivery Complete Ind.

bukrs like ekko-bukrs, "Company code

lnrze like lfb1-lnrze, "Vendor Head Office

lastact1(08) type c, "Last Activity Date

aedat1(08) type c, "Source List Create Date

end of x_hist.

data: t_hist like x_hist occurs 5000 with header line,

t_ekbe like ekbe occurs 100 with header line.

----


  • Selection Screen

----


selection-screen: begin of block block0

with frame

title text-000.

selection-screen: begin of block block1

with frame

title text-001.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (29) TEXT1 FOR FIELD p_since.

parameters: p_since like sy-datum.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) TEXT2 FOR FIELD S_EBELN.

select-options: s_ebeln for ekpo-ebeln.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) TEXT3 FOR FIELD s_werks.

select-options: s_werks for ekpo-werks.

SELECTION-SCREEN END OF LINE.

selection-screen: end of block block1.

selection-screen: begin of block block2

with frame

title text-002.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) TEXT4 FOR FIELD S_BUKRS.

select-options: s_bukrs for ekko-bukrs.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) TEXT5 FOR FIELD S_ekgrp.

select-options: s_ekgrp for marc-ekgrp.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) TEXT6 FOR FIELD S_ekorg.

select-options: s_ekorg for ekko-ekorg.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) text7 FOR FIELD S_lifnr.

select-options: s_lifnr for ekko-lifnr.

SELECTION-SCREEN end OF LINE.

selection-screen: skip.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) text8 FOR FIELD S_aedat.

select-options: s_aedat for ekko-aedat.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) text9 FOR FIELD S_vdatu.

select-options: s_vdatu for eord-vdatu.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) text10 FOR FIELD S_bdatu.

select-options: s_bdatu for eord-bdatu.

SELECTION-SCREEN end OF LINE.

selection-screen: skip.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) text11 FOR FIELD S_qty.

select-options: s_qty for ekbe-menge.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (26) text12 FOR FIELD S_value.

select-options: s_value for ekpo-netpr.

SELECTION-SCREEN end OF LINE.

selection-screen: skip.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (29) text13 FOR FIELD p_elikz.

parameters: p_elikz radiobutton group del.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (29) text14 FOR FIELD p_not.

parameters: p_not radiobutton group del.

SELECTION-SCREEN end OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (29) text15 FOR FIELD p_both.

parameters p_both radiobutton group del default 'X'.

SELECTION-SCREEN end OF LINE.

selection-screen: skip.

selection-screen begin of line.

selection-screen comment (29) parm1txt for field p_elikz.

parameters: p_purch as checkbox.

selection-screen end of line.

selection-screen: end of block block2.

selection-screen: end of block block0.

*----


  • INITIALIZATION:

*----


initialization.

move 'Purchasing Sort' to parm1txt.

TEXT1 = 'Since(p_since)'.

TEXT2 = 'Purchase Document No'.

text3 = 'Plant'.

TEXT4 = 'Company Code'.

text5 = 'Purchasing group'.

text6 = 'Purchasing organization'.

text7 = 'Vendor Number'.

text8 = 'Date on record was created'.

text9 = 'Source List Valid From Dte'.

text10 = 'Source List Validto Dte'.

text11 = 'Quantity'.

text12 = 'Net price in pur doc'.

text13 = 'Delivery completed indicator'.

text14 = 'Not'.

text15 = 'Both'.

*----


  • START-OF-SELECTION

*----


start-of-selection.

if p_since is initial.

p_since = sy-datum + 1.

endif.

select * from ekpo

where ebeln in s_ebeln

and werks in s_werks

and loekz eq ' '

and repos eq 'X'

and wepos eq 'X'

and ( pstyp eq '0' or pstyp eq '3' ).

if not p_not is initial.

check ekpo-elikz ne p_not.

endif.

if not p_elikz is initial.

check ekpo-elikz eq p_elikz.

endif.

clear: x_hist.

move-corresponding ekpo to x_hist.

shift x_hist-ebelp left deleting leading '0'.

shift x_hist-ebelp right deleting trailing space.

perform process_history.

if x_hist-lastact le p_since.

if x_hist-qtyrcvd ne x_hist-qtyinvd.

perform update_hist_table.

endif.

endif.

endselect.

end-of-selection.

*----


*

    • END-OF-SELECTION

**----


if p_purch is initial.

sort t_hist by absdiff descending ebeln ebelp.

else.

sort t_hist ascending by ebeln ebelp.

endif.

loop at t_hist.

clear t_hist-qtydiff.

t_hist-qtydiff = t_hist-qtyrcvd - t_hist-qtyinvd.

if not s_qty is initial.

check t_hist-qtydiff in s_qty.

endif.

if not s_value is initial.

check t_hist-valdiff in s_value.

endif.

w_hist-valdiff = w_hist-valdiff + t_hist-valdiff.

endloop.

  • if w_hist-valdiff ne '0'.

  • write: at c_col_13 'Total of Differences',

  • at c_col_17o w_hist-valdiff.

  • skip.

  • endif.

loop at t_hist.

t_hist-qtydiff = t_hist-qtyrcvd - t_hist-qtyinvd.

if not s_qty is initial.

check t_hist-qtydiff in s_qty.

endif.

if not s_value is initial.

check t_hist-valdiff in s_value.

endif.

endloop.

PERFORM f1000_layout_init CHANGING l_f_layout.

PERFORM flcat CHANGING l1t_fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'report_id'

  • 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 = ws_title

  • I_GRID_SETTINGS = 'center'

IS_LAYOUT = l_f_layout

IT_FIELDCAT = l1t_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

  • IT_ALV_GRAPHICS =

  • IT_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = t_hist

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

*CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

  • EXPORTING

  • IT_FIELDCAT = lt_fieldcat[]

  • TABLES

  • T_OUTTAB = t_hist.

*

&----


*& Form *F1000_Layout_Init

*----


FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.

CLEAR i_layout.

i_layout-colwidth_optimize = 'X'.

i_layout-edit = 'X'.

i_layout-ZEBRA = ''.

ENDFORM.

*----


  • Process table EKBE for Puchasing Document item history

*----


form process_history.

refresh: t_ekbe.

select * into table t_ekbe from ekbe

where ebeln eq ekpo-ebeln

and ebelp eq ekpo-ebelp.

loop at t_ekbe.

if t_ekbe-vgabe eq '1'.

if t_ekbe-shkzg eq 'H'.

subtract t_ekbe-menge from x_hist-qtyrcvd.

subtract t_ekbe-dmbtr from x_hist-amtrcvd. "WkReq #8526

else.

add t_ekbe-menge to x_hist-qtyrcvd.

add t_ekbe-dmbtr to x_hist-amtrcvd. "WkReq #8526

endif.

perform check_last_date.

endif.

if t_ekbe-vgabe eq '2'.

if t_ekbe-shkzg eq 'H'.

subtract t_ekbe-menge from x_hist-qtyinvd.

subtract t_ekbe-arewr from x_hist-amtinvd.

else.

add t_ekbe-menge to x_hist-qtyinvd.

add t_ekbe-arewr to x_hist-amtinvd.

endif.

perform check_last_date.

endif.

endloop.

endform.

*----


  • Get date of last Invoice or Receipt activity

*----


form check_last_date.

data: w_day(02) type c,

w_month(02) type c,

w_year(04) type c.

if t_ekbe-budat gt x_hist-lastact.

move t_ekbe-budat to x_hist-lastact.

clear: w_day,

w_month,

w_year.

w_day(2) = t_ekbe-budat+6(2).

w_month(2) = t_ekbe-budat+4(2).

w_year(2) = t_ekbe-budat+2(2).

concatenate w_month w_day w_year

into x_hist-lastact1 separated by '/'.

endif.

endform.

*----


  • Append new entry to internal table

*----


form update_hist_table.

clear: x_hist-vdatu,

x_hist-bdatu.

data: w_day(02) type c,

w_month(02) type c,

w_year(04) type c.

select single * from ekko

where ebeln eq ekpo-ebeln

and lifnr in s_lifnr

and bukrs in s_bukrs

and ekorg in s_ekorg

and aedat in s_aedat

and loekz eq ' '.

if sy-subrc eq 0.

move ekko-lifnr to x_hist-lifnr.

move ekko-aedat to x_hist-aedat.

MOVE EKKO-EKORG TO X_HIST-EKORG. "THIS IS WRITTEN BY ME

MOVE EKKO-BUKRS TO X_HIST-BUKRS. "THIS IS WRITTEN BY ME

select single name1 from lfa1 "WkRqst #8869 RCM

into x_hist-name1

where lifnr = x_hist-lifnr.

select single lnrze from lfb1 "Head Office (Invoice) Vendor

into x_hist-lnrze

where lifnr = x_hist-lifnr

and bukrs = x_hist-bukrs.

select single ekgrp from marc into x_hist-ekgrp

where matnr eq x_hist-matnr

and ekgrp in s_ekgrp

and werks eq x_hist-werks.

check sy-subrc eq 0.

if x_hist-ekgrp <> space. "WkRqst #8869 RCM

select single eknam from t024 "WkRqst #8869 RCM

into x_hist-eknam

where ekgrp = x_hist-ekgrp.

endif.

if not ekko-aedat is initial.

clear: w_day,

w_month,

w_year.

w_day(2) = ekko-aedat+6(2).

w_month(2) = ekko-aedat+4(2).

w_year(2) = ekko-aedat+2(2).

concatenate w_month w_day w_year

into x_hist-aedat1 separated by '/'.

else.

move ' ' to x_hist-aedat1.

endif.

  • clear: eord-vdatu,

  • eord-bdatu,

  • eord-erdat.

*

clear: eord.

select single * from eord

where lifnr eq x_hist-lifnr

and matnr eq x_hist-matnr

and werks eq x_hist-werks

and vdatu in s_vdatu

and bdatu in s_bdatu

and ebeln eq ekpo-ebeln.

  • check sy-subrc eq 0.

if not eord-vdatu is initial.

clear: w_day,

w_month,

w_year.

w_day(2) = eord-vdatu+6(2).

w_month(2) = eord-vdatu+4(2).

w_year(2) = eord-vdatu+2(2).

concatenate w_month w_day w_year

into x_hist-vdatu separated by '/'.

else.

move ' ' to x_hist-vdatu.

endif.

if not eord-bdatu is initial.

clear: w_day,

w_month,

w_year.

w_day(2) = eord-bdatu+6(2).

w_month(2) = eord-bdatu+4(2).

w_year(4) = eord-bdatu+0(4).

concatenate w_month w_day w_year

into x_hist-bdatu separated by '/'.

else.

move ' ' to x_hist-bdatu.

endif.

if x_hist-eknam = 'No longer in use'.

x_hist-eknam = ' '.

endif.

move-corresponding x_hist to t_hist.

perform calc_differences.

append t_hist.

endif.

endform.

----


  • FORM CALC_DIFFERENCES *

----


form calc_differences.

w_diff_qty = t_hist-qtyrcvd - t_hist-qtyinvd.

w_diff_amount = t_hist-amtrcvd - t_hist-amtinvd. "WkReq #8526

if t_hist-peinh gt 1.

w_po_price = t_hist-netpr / t_hist-peinh.

else.

w_po_price = t_hist-netpr.

endif.

t_hist-valdiff = w_diff_amount. "WkReq #8526

if t_hist-valdiff lt 0.

t_hist-absdiff = t_hist-absdiff - t_hist-valdiff.

else.

t_hist-absdiff = t_hist-valdiff.

endif.

endform.

*======================================================

  • Field catalog form routine

*======================================================

FORM flcat CHANGING l1t_fieldcat TYPE slis_t_fieldcat_alv.

DATA: lt_fieldcat TYPE slis_fieldcat_alv.

CLEAR lt_fieldcat.

lt_fieldcat-col_pos = 1.

lt_fieldcat-fieldname = 'EBELN'.

lt_fieldcat-seltext_l = 'PurDoc'.

lt_fieldcat-outputlen = 18.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 2.

lt_fieldcat-fieldname = 'EBELP'.

lt_fieldcat-seltext_l = 'Line'.

lt_fieldcat-outputlen = 10.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 3.

lt_fieldcat-fieldname = 'ELIKZ'.

lt_fieldcat-seltext_l = 'DC'.

lt_fieldcat-outputlen = 5.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 4.

lt_fieldcat-fieldname = 'AEDAT1'.

lt_fieldcat-seltext_l = 'PurOrdCrtdt'.

lt_fieldcat-outputlen = 12.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 5.

lt_fieldcat-fieldname = 'VDATU'.

lt_fieldcat-seltext_l = 'SrcFrdte'.

lt_fieldcat-outputlen = 12.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 6.

lt_fieldcat-fieldname = 'BDATU'.

lt_fieldcat-seltext_l = 'SrcToDte'.

lt_fieldcat-outputlen = 3.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 7.

lt_fieldcat-fieldname = 'LASTACT1'.

lt_fieldcat-seltext_l = 'LastAct'.

lt_fieldcat-outputlen = 10.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 8.

lt_fieldcat-fieldname = 'MATNR'.

lt_fieldcat-seltext_l = 'Material'.

lt_fieldcat-outputlen = 5.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 9.

lt_fieldcat-fieldname = 'EKGRP'.

lt_fieldcat-seltext_l = 'Purgrp'.

lt_fieldcat-outputlen = 13.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 10.

lt_fieldcat-fieldname = 'EKNAM'.

lt_fieldcat-seltext_l = 'PurGrpName'.

lt_fieldcat-outputlen = 15.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 11.

lt_fieldcat-fieldname = 'WERKS'.

lt_fieldcat-seltext_l = 'Plant'.

lt_fieldcat-outputlen = 8.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 12.

lt_fieldcat-fieldname = 'LIFNR'.

lt_fieldcat-seltext_l = 'Vendor'.

lt_fieldcat-outputlen = 8.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 13.

lt_fieldcat-fieldname = 'LNRZE'.

lt_fieldcat-seltext_l = 'HeadOffVendor'.

lt_fieldcat-outputlen = 15.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 14.

lt_fieldcat-fieldname = 'NAME1'.

lt_fieldcat-seltext_l = 'VendorName'.

lt_fieldcat-outputlen = 15.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 15.

lt_fieldcat-fieldname = 'BUKRS'.

lt_fieldcat-seltext_l = 'CCode'.

lt_fieldcat-outputlen = 6.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 16.

lt_fieldcat-fieldname = 'EKORG'.

lt_fieldcat-seltext_l = 'PurOrg'.

lt_fieldcat-outputlen = 6.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 17.

lt_fieldcat-fieldname = 'QTYRCVD'.

lt_fieldcat-seltext_l = 'QtyRecv'.

lt_fieldcat-outputlen = 12.

APPEND lt_fieldcat to l1t_fieldcat.

lt_fieldcat-col_pos = 18.

lt_fieldcat-fieldname = 'QTYINVD'.

lt_fieldcat-seltext_l = 'QtyInv'.

lt_fieldcat-outputlen = 12.

APPEND lt_fieldcat to l1t_fieldcat.

  • lt_fieldcat-col_pos = 19.

  • lt_fieldcat-fieldname = 'QTYDIFF'.

  • lt_fieldcat-seltext_l = 'QtyInv'.

  • lt_fieldcat-outputlen = 12.

  • APPEND lt_fieldcat.

lt_fieldcat-col_pos = 20.

lt_fieldcat-fieldname = 'VALDIFF'.

lt_fieldcat-seltext_l = 'DiffVal'.

lt_fieldcat-outputlen = 12.

APPEND lt_fieldcat to l1t_fieldcat.

endform.

Thanks in Adnvace

1 REPLY 1

Former Member
0 Kudos

It looks like you dont have the MODIFY statement in the loops where you calculate the QTYDIFF value.

Try:

loop at t_hist.

clear t_hist-qtydiff.

t_hist-qtydiff = t_hist-qtyrcvd - t_hist-qtyinvd.

if not s_qty is initial.

check t_hist-qtydiff in s_qty.

endif.

if not s_value is initial.

check t_hist-valdiff in s_value.

endif.

w_hist-valdiff = w_hist-valdiff + t_hist-valdiff.

<b>MODIFY t_hist from w_hist.</b>

endloop.

Do the same for the other t_hist table loop.

Brad