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: 

hi there, any one please help me,

Former Member
0 Kudos

hi there all,

i really need some help regarding some modification,

it is very urgetn thing,

really really looking for some one to help me.

i need to do some modifications to the alv_form,

im new to this, plz help me.

thank.

2 REPLIES 2

former_member554978
Active Contributor
0 Kudos

Hi Vasanthan,

Please Refer the below code for ALV:

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

NO STANDARD PAGE HEADING.

*

*DATA DECLARION

INCLUDE znbrfi_tributecode_top.

*

*

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

  • SELECTION SCREEN *

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

*

**Selection screen to get the file path

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME.

*

PARAMETERS : p_fname LIKE rlgrap-filename.

  • DEFAULT '/data/sap/D12/interface/SAP-BR-IF0044/out/Thur.txt'.

SELECTION-SCREEN SKIP 1.

*PARAMETERS : prc_date LIKE sy-datum.

*

SELECTION-SCREEN : END OF BLOCK b1.

*

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

  • INCLUDE SELECTION *

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

*

**INCLUDE CONTAINS SUBROTINES

INCLUDE znbrfi_tribute_select.

*

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

  • START-OF-SELECTION *

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

START-OF-SELECTION.

*

**SUBROTINES CONTAINS ALL PERFORMS

PERFORM procmain.

****************************topinclude**********************************

&----


*& Include ZNBRFI_TRIBUTECODE_TOP *

&----


*

**Type Decalartion

TYPE-POOLS:slis.

*

*

TYPES: BEGIN OF gy_finallist,

rec_typ(1) TYPE i, "antwt, "Record type

sys_cde TYPE ktosl, "System code

lnr_dt TYPE madat, "Interface date

vnd_num TYPE blknr, "Vendor number

vnd_cnpj TYPE ahdat, "Vendor CNPJ

cmp_cde TYPE ahdat, "Company code

cmpcd_cnpj TYPE ahdat, "Company code CNPJ

wthtx_cd TYPE wt_withcd, "Withholding tax code

wthtx_ty TYPE witht, "withhoding tax type

off_cll TYPE aapct, "Official collection

cst_cnt TYPE abeln, "Cost center

pst_dt TYPE madat, "Posting date

pst_ty TYPE antwt, "Posting type

sub_jud TYPE mwart, "Sub-judice

doc_num TYPE bnkid, "Document number

rldoc_num TYPE bnkid, "Related document number

fis_num TYPE finnr, "Notafiscal number

blank TYPE abntp, "Blank

gis_grs TYPE btwnr, "Nota fiscal gross amount

txbsamt TYPE btwnr, "Tax base amount

txamt TYPE btwnr, "Tax amount

whdtxrt TYPE p06_indicatif, "Withholding tax rate

docty TYPE abelp, "Document type

docser TYPE abrkn, "Document series

fisenum TYPE mwart, "Nota fiscal E-number

isscd TYPE assed, "atfbz, "ISS sevice code

city TYPE bedr, "City

cmnts TYPE msgli, "Comments

extrflds TYPE ofx_memo2, "Extra fields

END OF gy_finallist,

*

gt_finallist TYPE STANDARD TABLE OF gy_finallist.

*

DATA: lw_finallist TYPE gy_finallist,

lv_len TYPE abnum.

*This structure is to display the sub total based on the company code CNPJ field

TYPES: BEGIN OF gy_finallist1,

rec_typ TYPE antwt, "Record type

sys_cde TYPE ktosl, "System code

lnr_dt TYPE madat, "Interface date

vnd_num TYPE blknr, "Vendor number

vnd_cnpj TYPE ahdat, "Vendor CNPJ

cmp_cde TYPE ahdat, "Company code

cmpcd_cnpj TYPE ahdat, "Company code CNPJ

wthtx_cd TYPE wt_withcd, "Withholding tax code

wthtx_ty TYPE witht, "withhoding tax type

off_cll TYPE aapct, "Official collection

cst_cnt TYPE abeln, "Cost center

pst_dt TYPE madat, "Posting date

pst_ty TYPE antwt, "Posting type

sub_jud TYPE mwart, "Sub-judice

doc_num TYPE bnkid, "Document number

rldoc_num TYPE bnkid, "Related document number

fis_num TYPE finnr, "Notafiscal number

blank TYPE abntp, "Blank

gis_grs TYPE btwnr, "Nota fiscal gross amount

txbsamt TYPE btwnr, "Tax base amount

txamt TYPE btwnr, "Tax amount

whdtxrt TYPE p06_indicatif, "Withholding tax rate

docty TYPE abelp, "Document type

docser TYPE abrkn, "Document series

fisenum TYPE mwart, "Nota fiscal E-number

isscd TYPE assed, "atfbz, "ISS sevice code

city TYPE bedr, "City

cmnts TYPE msgli, "Comments

extrflds TYPE ofx_memo2, "Extra fields

END OF gy_finallist1,

*

gt_finallist1 TYPE STANDARD TABLE OF gy_finallist1.

******************************maininclude******************************************

&----


*& Include ZNBRFI_TRIBUTE_SELECT *

&----


*

**Internal Table Declartion

DATA : lt_fldcatlog TYPE slis_t_fieldcat_alv ,

lw_fldcatlog TYPE slis_fieldcat_alv ,

lw_gs_layout TYPE slis_layout_alv,

ls_disvariant TYPE disvariant,

ls_list_comments TYPE slis_t_listheader,

ts_list_comments_ln LIKE LINE OF ls_list_comments,

lt_finallist TYPE STANDARD TABLE OF gy_finallist.

*

DATA: lt_sortcat TYPE slis_t_sortinfo_alv,

lc_sortcat_ln LIKE LINE OF lt_sortcat.

*

**Constants Declartion.

CONSTANTS: lc_hdtxt TYPE mwart VALUE 'H',

lc_callback_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

lc_save_standard TYPE char1 VALUE 'A',

lc_flag TYPE mwart VALUE 'X'.

*

&----


*& Form procmain

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM procmain .

*

**TO FETECH THE DATA FROM APPLICATION SERVER

PERFORM procgetdata CHANGING lt_finallist.

*

**To display the heading

PERFORM procheadingdata USING lt_finallist

CHANGING ls_list_comments.

*

**To populate the subtotal into the alv formate

PERFORM sort_fields.

*

**To display the data in ALV formate

PERFORM procdisplaydata USING sy-repid

lt_finallist.

*

ENDFORM. " PROCMAIN

&----


*& Form PROCGETDATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM procgetdata CHANGING ct_finallist TYPE gt_finallist.

DATA: lw_finallist1 TYPE gy_finallist1,

lv_sl_number TYPE abnum.

DATA:ct_finallist1 TYPE STANDARD TABLE OF gy_finallist1.

*

    • To get the data from application server

OPEN DATASET p_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.

*

IF sy-subrc IS INITIAL.

*

DO.

READ DATASET p_fname INTO lw_finallist1 ACTUAL LENGTH lv_len.

  • CONDENSE lw_finallist-GIS_GRS NO-GAPS.

IF sy-subrc IS INITIAL.

*

APPEND lw_finallist1 TO ct_finallist1.

CLEAR lw_finallist1.

SORT ct_finallist1 BY cmp_cde.

SORT ct_finallist1 BY doc_num.

ELSE.

EXIT.

ENDIF.

ENDDO.

ELSE.

MESSAGE e398(00) WITH text-131. "error message File is Empty

ENDIF.

*

CLEAR lw_finallist1.

REFRESH ct_finallist.

LOOP AT ct_finallist1 INTO lw_finallist1.

*

**FM is to convert the numerical value into interger value

CALL FUNCTION 'CONVERT_STRING_TO_INTEGER'

EXPORTING

p_string = lw_finallist1-rec_typ

IMPORTING

p_int = lw_finallist-rec_typ

EXCEPTIONS

OVERFLOW = 1

INVALID_CHARS = 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.

*

**Move the data into final internal table

MOVE:lw_finallist1-sys_cde TO lw_finallist-sys_cde,

lw_finallist1-lnr_dt TO lw_finallist-lnr_dt,

lw_finallist1-vnd_num TO lw_finallist-vnd_num,

lw_finallist1-vnd_cnpj TO lw_finallist-vnd_cnpj,

lw_finallist1-cmp_cde TO lw_finallist-cmp_cde,

lw_finallist1-cmpcd_cnpj TO lw_finallist-cmpcd_cnpj,

lw_finallist1-wthtx_cd TO lw_finallist-wthtx_cd,

lw_finallist1-wthtx_ty TO lw_finallist-wthtx_ty,

lw_finallist1-off_cll TO lw_finallist-off_cll,

lw_finallist1-cst_cnt TO lw_finallist-cst_cnt,

lw_finallist1-pst_dt TO lw_finallist-pst_dt,

lw_finallist1-pst_ty TO lw_finallist-pst_ty,

lw_finallist1-sub_jud TO lw_finallist-sub_jud,

lw_finallist1-doc_num TO lw_finallist-doc_num,

lw_finallist1-rldoc_num TO lw_finallist-rldoc_num,

lw_finallist1-fis_num TO lw_finallist-fis_num,

lw_finallist1-blank TO lw_finallist-blank,

lw_finallist1-gis_grs TO lw_finallist-gis_grs,

lw_finallist1-txbsamt TO lw_finallist-txbsamt,

lw_finallist1-txamt TO lw_finallist-txamt,

lw_finallist1-whdtxrt TO lw_finallist-whdtxrt,

lw_finallist1-docty TO lw_finallist-docty,

lw_finallist1-docser TO lw_finallist-docser,

lw_finallist1-fisenum TO lw_finallist-fisenum,

lw_finallist1-isscd TO lw_finallist-isscd,

lw_finallist1-city TO lw_finallist-city,

lw_finallist1-cmnts TO lw_finallist-cmnts,

lw_finallist1-extrflds TO lw_finallist-extrflds.

  • CLEAR lv_sl_number.

  • lv_sl_number = lv_sl_number + 1.

  • MOVE lv_sl_number TO lw_finallist1-sl_number.

APPEND lw_finallist TO ct_finallist.

ENDLOOP.

*

ENDFORM. " PROCGETDATA

&----


*& Form PROCDISPLAYDATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM procdisplaydata USING uv_callback_program TYPE sy-repid

ut_finallist TYPE gt_finallist.

*

**To populate the data into ALV structure

lw_gs_layout-colwidth_optimize = lc_flag.

*

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'SYS_CDE'(002)

''

text-102 2.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'LNR_DT'(003)

''

text-103 3.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'VND_NUM'(004)

''

text-104 4.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'VND_CNPJ'(005)

''

text-105 5.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'CMP_CDE'(006)

''

text-106 6.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'CMPCD_CNPJ'(007)

''

text-107 7.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'WTHTX_CD'(008)

''

text-108 8.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'WTHTX_TY'(009)

''

text-109 9.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'OFF_CLL'(010)

''

text-110 10.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'CST_CNT'(011)

''

text-111 11.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'PST_DT'(012)

''

text-112 12.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'PST_TY'(013)

''

text-113 13.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'SUB_JUD'(014)

''

text-114 14.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'DOC_NUM'(015)

''

text-115 15.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'RLDOC_NUM'(016)

''

text-116 16.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'FIS_NUM'(017)

''

text-117 17.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'BLANK'(018)

''

text-118 18.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'GIS_GRS'(019)

''

text-119 19.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'TXBSAMT'(020)

''

text-120 20.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'TXAMT'(021)

''

text-121 21.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'WHDTXRT'(022)

''

text-122 22.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'DOCTY'(023)

''

text-123 23.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'DOCSER'(024)

''

text-124 24.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'FISENUM'(025)

''

text-125 25.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'ISSCD'(026)

''

text-126 26.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'CITY'(027)

''

text-127 27.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'CMNTS'(028)

''

text-128 28.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'EXTRFLDS'(029)

''

text-129 29.

*

PERFORM fill_fields_of_fieldcatlog TABLES lt_fldcatlog

USING 'UT_FINALLIST'(030)

'REC_TYP'(001)

''

text-101 1.

*

*

lw_gs_layout-totals_text = 'TOTAL'.

lw_gs_layout-subtotals_text = 'Sub total'.

lw_gs_layout-zebra = lc_flag.

ls_disvariant-report = uv_callback_program.

ls_disvariant-username = sy-uname.

*

*

**Funtion module is to display the report in ALV formate.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = uv_callback_program

i_callback_top_of_page = lc_callback_top_of_page

is_layout = lw_gs_layout

it_fieldcat = lt_fldcatlog

i_default = lc_flag

i_save = lc_save_standard

is_variant = ls_disvariant

it_sort = lt_sortcat[]

TABLES

t_outtab = ut_finallist

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc IS NOT INITIAL.

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

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

ENDIF.

*

*

ENDFORM. " PROCDISPLAYDATA

&----


  • text

----


  • -->T_FLDCATLOG text

  • -->P_0015 text

  • -->P_0016 text

  • -->P_0017 text

  • -->P_TEXT_100 text

  • -->P_1 text

----


FORM fill_fields_of_fieldcatlog TABLES t_fieldcatlog

STRUCTURE lw_fldcatlog

USING p_tabname

p_fieldname

p_key

p_seltext_l

p_col_pos

.

*

**To populate the fieldcatlog

lw_fldcatlog-tabname = p_tabname.

lw_fldcatlog-fieldname = p_fieldname.

lw_fldcatlog-key = p_key.

lw_fldcatlog-seltext_l = p_seltext_l.

lw_fldcatlog-col_pos = p_col_pos.

IF p_fieldname EQ 'REC_TYP'.

lw_fldcatlog-do_sum = lc_flag.

ENDIF.

**

*

APPEND lw_fldcatlog TO lt_fldcatlog.

CLEAR : lw_fldcatlog .

*

ENDFORM. " fill_fields_of_fieldcatlog

&----


*& Form procheadingdata

&----


  • text

----


  • <--P_LS_LIST_COMMENTS text

----


FORM procheadingdata USING ut_finallist TYPE gt_finallist

CHANGING ts_list_comments TYPE slis_t_listheader.

*

**To populate the text to display the heading

DATA: lv_count TYPE kunnr,

lv_text_con TYPE char90,

lv_count1 TYPE kunnr.

*

**To display the main heading in the report

ts_list_comments_ln-typ = lc_hdtxt.

ts_list_comments_ln-info = text-130.

APPEND ts_list_comments_ln TO ls_list_comments.

ENDFORM. " procheadingdata

*&----


**& Form TOP-OF-PAGE

*&----


    • text - To display the details on Top of Page

*----


FORM top_of_page.

*

**To display the heading and subheading

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = ls_list_comments.

CLEAR : ls_list_comments.

REFRESH : ls_list_comments.

ENDFORM. " proctax_dispdata

&----


*& Form sort_fields

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sort_fields .

*

**To display the subtotal based on the company code CNPJ field

lc_sortcat_ln-fieldname = 'CMPCD_CNPJ'(007).

lc_sortcat_ln-tabname = 'UT_FINALLIST'(030).

lc_sortcat_ln-spos = 1.

lc_sortcat_ln-up = lc_flag. "Sort order: Ascending

  • lc_sortcat_ln-down = space. "Sort order: Descending

lc_sortcat_ln-subtot = lc_flag. "Subtotals defined flag

APPEND lc_sortcat_ln TO lt_sortcat.

CLEAR lc_sortcat_ln.

*

lc_sortcat_ln-fieldname = 'REC_TYP'(001).

lc_sortcat_ln-tabname = 'UT_FINALLIST'(030).

lc_sortcat_ln-spos = 2.

lc_sortcat_ln-up = 'X'. "Sort order: Ascending

  • lc_sortcat_ln-down = 'X'.

APPEND lc_sortcat_ln TO lt_sortcat.

CLEAR lc_sortcat_ln.

*

ENDFORM. " sort_fields

Thanks.

Note:Reward Points if you find useful.

Former Member
0 Kudos

check tcode SMARTFORMS in SAP , and press F4 , then u will get list of SF avail. in ur system with descriptions.

also

Check these

for invoice LB_BIL_INVOICE

Purchase Order MEDRUCK

Sales Order RVORDER01

Standard form for PO Smartforms is ‘/SMB40/MMPO_L’ .

and also check ME9A

Just try out the program in this link.

http://www.sap-img.com/smartforms/search-for-standard-or-customise-smartform.htm

Reward points if useful.