‎2007 Sep 04 6:45 AM
Dear Experts,
I have to add one field at the last of the of a ALV. THe field name is ebeln.
I have made modifiaction in the structure as well as in the fieldcat.
please go through the complete code below.
************************************************************************
Program name : Z_Invoice *
Program Description : The purpose of the report is to: *
Give the details of open invoices for a *
project. *
Give details of cleared invoices for a *
project *
Technical Object No : NA *
Developer : Priyanka Vasudeva,Jasleen Randhawa *
Level2 Analyst/FC : Sanjay Arali *
Company : Satyam Computer Services Limited(SCSL) *
Start Date : 12-05-2005 *
End Date : 18-05-2005 *
Logical Database : NA *
Function Modules : HR_SEN_CALE_DAYS_DATE, *
REUSE_ALV_LIST_DISPLAY, *
HR_HK_DIFF_BT_2_DATES *
Includes : z_invoice_form - For forms *
z_invoice_top - For data Declarations *
************************************************************************
C H A N G E H I S T O R Y *
************************************************************************
*Version| Developer | Date | Change Description *
----
V00 |Priyanka ,Jasleen |12/10/2004| New Development
----
*
************************************************************************
report z_invoice message-id znew.
Include for the data declarations and selection screen
include z_invoice_top.
Include for the forms used
include z_invoice_form.
************************************************************************
I N I T I A L I Z A T I O N *
************************************************************************
initialization.
Storing the report name
v_repid = sy-repid.
************************************************************************
A T S E L E C T I O N - S C R E E N *
************************************************************************
at selection-screen.
For validating the Project number entered by the user
perform f_validate_proj_number.
************************************************************************
S T A R T - O F - S E L E C T I O N *
************************************************************************
start-of-selection.
For creating the field catalog
perform f_fieldcat.
*For checking the project number in lowercse
perform f_projectno_concatenate.
if p_open = 'X'.
*For open invoices
perform f_invoice_open.
elseif p_closed = 'X'.
*For cleared invoices
perform f_invoice_cleared.
endif.
For vendor details
perform f_vendor_details.
Display the Final Output in ALV
perform f_alv_display.
************************************************************************
E N D - O F - S E L E C T I O N *
************************************************************************
*Free all internal tables
free: i_output1,
i_fieldcat,
i_bsak,
i_bsik.
************************************************************************
E N D O F R E P O R T *
************************************************************************
************************************************************************
Program name : Z_Invoice *
Program Description : The purpose of the report is to: *
Give the details of open invoices for a *
project. *
Give details of cleared invoices for a
project
Technical Object No : NA *
Developer : Priyanka Vasudeva,Jasleen Randhawa
Level2 Analyst/FC : Sanjay Arali *
Company : Satyam Computer Services Limited(SCSL) *
Start Date : 12-05-2005 *
End Date : 17-05-2005 *
Logical Database : NA *
Function Modules : HR_SEN_CALE_DAYS_DATE, *
REUSE_ALV_LIST_DISPLAY, *
HR_HK_DIFF_BT_2_DATES *
Includes : z_invoice_form - For forms *
z_invoice_top - For data Declarations *
************************************************************************
C H A N G E H I S T O R Y *
************************************************************************
*Version| Developer | Date | Change Description *
----
V00 |Priyanka ,Jasleen |12/10/2004| New Development *
----
*
************************************************************************
----
INCLUDE Z_INVOICE_TOP *
----
include <icon>.
type-pools: slis.
************************************************************************
D A T A B A S E T A B L E S *
************************************************************************
tables: bsak, "accounting:secondary index for vendors(cleared items)
bsik, "accounting:secondary index for vendors
lfa1, "vendor master
proj. "project definition
I N T E R N A L T A B L E S ***********************
For the complete details to be shown on the output screen
data: begin of i_output1 occurs 0,
lifnr like lfa1-lifnr, "vendor no
name(70), "vendor name1
belnr like bsak-belnr, "document no
bldat like bsak-bldat, "document date
dmbtr like bsak-dmbtr, "amount in local currency
waers LIKE bsak-waers, "currency
augdt like bsak-augdt, "date paid
zuonr like bsak-zuonr, "assignment number
due_date like bsik-zfbdt, "due date
status(4), "To set color
g_days like p0347-scrdd, "date paid
end of i_output1.
*For open invoices
data: begin of i_bsak occurs 0,
lifnr like bsak-lifnr,
belnr like bsak-belnr, "document no
bldat like bsak-bldat, "document date
dmbtr like bsak-dmbtr, "amount in local currency
waers LIKE bsak-waers, "currency
augdt like bsak-augdt, "date paid
zuonr like bsak-zuonr, "assignment number
bukrs like bsak-bukrs, "company code
blart like bsak-blart, "document type
shkzg like bsak-shkzg, "Type Credit Or Debit
end of i_bsak.
*For vendor details including vendor number and name
data: begin of i_lfa1 occurs 0,
lifnr like lfa1-lifnr, "vendor no
name1 like lfa1-name1, "vendor name1
name2 like lfa1-name2, "vendor name2
end of i_lfa1.
*For closed invoices
data: begin of i_bsik occurs 0,
lifnr like bsik-lifnr, "vendor no
belnr like bsik-belnr, "document no
bldat like bsik-bldat, "document date
dmbtr like bsik-dmbtr, "amount in local currency
waers LIKE bsik-waers, "currency
blart like bsik-blart, "document type
zfbdt like bsik-zfbdt, "baseline date for due date
zbd1t like bsik-zbd1t, "cash discount days1
augdt like bsik-augdt, "date paid
zuonr like bsik-zuonr, "assignment number
bukrs like bsik-bukrs, "company code
shkzg like bsik-shkzg, "Type Credit Or Debit
end of i_bsik.
************************************************************************
D A T A D E C L A R A T I O N S *
************************************************************************
data: v_repid type sy-repid, "For the report name
v_projno type bsak-zuonr,
v_projno1(25) type c.
T A B L E T Y P E S *****************************
Internal Table for Field Catalog
data i_fieldcat type slis_t_fieldcat_alv.
W O R K A R E A S *************************
Work Area for Field Catalog
data wa_fieldcat type slis_fieldcat_alv.
************************************************************************
S E L E C T I O N S C R E E N *
************************************************************************
selection-screen skip 1.
selection-screen begin of block input with frame title text-001.
selection-screen skip 1.
parameters: p_projno type proj-pspid obligatory.
selection-screen skip 2.
parameters: p_open radiobutton group inv,
p_closed radiobutton group inv.
selection-screen skip 1.
selection-screen end of block input.
************************************************************************
Program name : Z_Invoi ce *
Program Description : The purpose of the report is to: *
Give the details of open invoices for a *
project. *
Give details of cleared invoices for a *
project
Technical Object No : NA *
Developer : Priyanka Vasudeva,Jasleen Randhawa
Level2 Analyst/FC : Sanjay Arali *
Company : Satyam Computer Services Limited(SCSL) *
Start Date : 12-05-2005 *
End Date : 17-05-2005 *
Logical Database : NA *
Function Modules : HR_SEN_CALE_DAYS_DATE, *
REUSE_ALV_LIST_DISPLAY, *
HR_HK_DIFF_BT_2_DATES *
Includes : z_invoice_form - For forms *
z_invoice_top - For data Declarations *
************************************************************************
C H A N G E H I S T O R Y *
************************************************************************
*Version| Developer | Date | Change Description *
----
V00 |Priyanka ,Jasleen |12/10/2004| New Development
----
V01 | | | *
----
*
************************************************************************
----
INCLUDE Z_INVOICE_FORM *
----
************************************************************************
Form To Create a FieldCatalog *
************************************************************************
form f_fieldcat.
clear wa_fieldcat.
lifnr
wa_fieldcat-ref_fieldname = 'LIFNR'.
wa_fieldcat-fieldname = 'LIFNR'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Vendor No'(004).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
NAME
wa_fieldcat-ref_fieldname = 'NAME'.
wa_fieldcat-fieldname = 'NAME'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Vendor Name'(005).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
BELNR
wa_fieldcat-ref_fieldname = 'BELNR'.
wa_fieldcat-fieldname = 'BELNR'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Document No'(006).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
BLDAT
wa_fieldcat-ref_fieldname = 'BLDAT'.
wa_fieldcat-fieldname = 'BLDAT'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Document Date'(007).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
DMBTR
wa_fieldcat-ref_fieldname = 'DMBTR'.
wa_fieldcat-ref_tabname = 'BSIK'.
wa_fieldcat-fieldname = 'DMBTR'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_m = 'Amount in LC'(008).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
WAERS
wa_fieldcat-ref_fieldname = 'WAERS'.
wa_fieldcat-fieldname = 'WAERS'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Currency'(009).
wa_fieldcat-no_zero = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
if p_open = 'X'.
due date
wa_fieldcat-fieldname = 'DUE_DATE'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Due Date'(010).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
Status
wa_fieldcat-fieldname = 'STATUS'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Status'.
wa_fieldcat-just = 'C'.
wa_fieldcat-icon = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
G_DAYS
wa_fieldcat-fieldname = 'G_DAYS'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Days Past Due'(011).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
*AUGDT
wa_fieldcat-ref_fieldname = 'AUGDT'.
wa_fieldcat-fieldname = 'AUGDT'.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'Date Paid'(012).
wa_fieldcat-no_zero = 'X'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
elseif p_closed = 'X'.
endif.
endform.
&----
*& Form F_VALIDATE_Project_Number
&----
Form to validate the Project number entered by the user
----
form f_validate_proj_number.
Validation of Project numbers entered on the selection screen
select single pspid
from proj
into proj-pspid
where pspid = p_projno.
if sy-subrc ne 0.
message e100.
endif.
endform.
&----
*& Form F_projectno_conctenate
&----
Form to check for the project number.
----
form f_projectno_concatenate.
concatenate p_projno(1) '-' p_projno+1(23)
into v_projno.
v_projno1 = v_projno.
translate v_projno1 to lower case.
endform.
&----
*& Form F_invoice_open
&----
Form to get the details for open invoices
----
form f_invoice_open.
data: l_dat type endda,
l_date type begda,
l_days type psen_duration_dec,
l_outdate like p0347-scrdd,
l_date1 type dats,
l_date2 type dats,
l_days1(6) type c,
l_days2(6) type c.
select lifnr "vendor no
belnr "document no
bldat "document date
dmbtr "amount in LC
waers "currency
blart "document type
zfbdt "baseline date for due date
zbd1t "cash discount days1
augdt "date paid
zuonr "assignment number
bukrs "company code
shkzg "Type Credit or Debit
from bsik
into corresponding fields of table i_bsik
where ( zuonr = v_projno
or zuonr = v_projno1 )
and bukrs = 'AIC'
AND ( blart = 'RE' OR blart = 'KZ' )
and umsks eq space.
loop at i_bsik.
i_output1-lifnr = i_bsik-lifnr.
i_output1-belnr = i_bsik-belnr.
i_output1-dmbtr = i_bsik-dmbtr.
i_output1-bldat = i_bsik-bldat.
i_output1-waers = i_bsik-waers.
i_output1-zuonr = i_bsik-zuonr.
l_days-caldd = i_bsik-zbd1t.
l_date = i_bsik-zfbdt.
*Modification for Account Payable
if i_bsik-BLART = 'KZ' .
if i_bsik-shkzg = 'H' .
i_output1-dmbtr = 0 - i_bsik-dmbtr .
endif.
to add baseline date and accounts recievable days1
call function 'HR_SEN_CALE_DAYS_DATE'
exporting
id_date = l_date
id_operator = '+'
is_duration = l_days
importing
ed_date = l_dat
exceptions
conversion_not_specified = 1
conversion_not_possible = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
i_output1-due_date = l_dat.
if sy-datum > l_dat.
l_date1 = sy-datum.
l_date2 = l_dat.
else.
l_date1 = l_dat.
l_date2 = sy-datum.
endif.
*to calculate difference between the due date and currrent date
call function 'HR_HK_DIFF_BT_2_DATES'
exporting
date1 = l_date1
date2 = l_date2
output_format = '02'
importing
days = l_outdate
exceptions
invalid_dates_specified = 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.
l_days2 = l_outdate.
if sy-datum le l_dat.
i_output1-status = icon_green_light.
concatenate '-' l_days2 into l_days1.
i_output1-g_days = l_days1.
elseif sy-datum gt l_dat.
i_output1-status = icon_red_light.
concatenate '+' l_days2 into l_days1.
i_output1-g_days = l_days1.
endif.
append i_output1.
endloop.
endform.
&----
*& Form F_vendor_details
&----
Form to get the details of vendors
----
form f_vendor_details.
*to get vendor details
loop at i_output1.
select single lifnr "vendor no
name1 " vendor name1
name2 " vendor name2
from lfa1
into i_lfa1
where lifnr = i_output1-lifnr.
if sy-subrc = 0.
i_output1-lifnr = i_lfa1-lifnr.
concatenate i_lfa1-name1 i_lfa1-name2
into i_output1-name
separated by space.
modify i_output1.
endif.
endloop.
endform.
&----
*& Form F_invoice_cleared
&----
Form to get the details for cleared invoices
----
form f_invoice_cleared.
select lifnr "vendor no
belnr "document no
bldat "document date
dmbtr "amount in LC
waers "currency
augdt "date paid
zuonr "assignment number
bukrs "company code
blart "document type
*Added for
shkzg "Type Credit or Debit
from bsak
into table i_bsak
where ( zuonr = v_projno
or zuonr = v_projno1 )
and bukrs = 'AIC'
AND ( blart = 'RE'
OR blart = 'KZ' )
and umsks eq space.
loop at i_bsak.
i_output1-lifnr = i_bsak-lifnr.
i_output1-belnr = i_bsak-belnr.
i_output1-dmbtr = i_bsak-dmbtr.
i_output1-bldat = i_bsak-bldat.
i_output1-waers = i_bsak-waers.
i_output1-augdt = i_bsak-augdt.
i_output1-zuonr = i_bsak-zuonr.
*Modification for Account Payable
If i_BSAK-BLART = 'KZ' .
if i_bsak-shkzg = 'H' .
i_output1-dmbtr = 0 - i_bsak-dmbtr.
endif.
append i_output1.
endloop.
endform.
----
FORM f_alv_display *
----
........ *
----
form f_alv_display.
data:wa_layout type slis_layout_alv,
v_title type lvc_title,
wa_variant like disvariant. "For default variant
if p_open = 'X'.
concatenate 'Open Invoices for Project:'(003) v_projno into
v_title separated by space.
wa_variant-variant = '/DEFAULT1'.
else.
concatenate 'Cleared Invoices for Project:'(002) v_projno into
v_title separated by space.
wa_variant-variant = '/DEFAULT'.
endif.
wa_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
is_layout = wa_layout
i_grid_title = v_title
it_fieldcat = i_fieldcat[]
i_save = 'A'
is_variant = wa_variant
tables
t_outtab = i_output1
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.
endform.
***************************************************************************
But after doing these changes as i mentioned above , i am not able to get the
catalog in the ALV.
Please help!!!
i wanted to send you all the picture of ALV, But i am not able to paste it,
can i post picture inthis , if possible pl tell.
Thanks
Neeraj
‎2007 Sep 04 6:52 AM
execute ur report and click on change layout..c whether da field u entered is under hidden columns..if yes move it to displayed columns..
plz reward points if dis helps
‎2007 Sep 04 6:56 AM
Hello,
to get it in ALV , there needs to be an append of EBELN to the field catalogue
ebeln
wa_fieldcat-fieldname = 'EBELN''.
wa_fieldcat-tabname = 'I_OUTPUT1'.
wa_fieldcat-seltext_m = 'EBELN'(009).
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
Please check if you have added it to the field catalog.......
In addition to it,before calling the reuse_ALV function put a breakpoint and see if the internal table 'I_OUTPUT1' contains EBELN and all relevant data....
Reward if useful and pls reply if you rectified the problem
Regards
Byju