Application Development and Automation 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: 
Read only

FUNCTION 'REUSE_ALV_GRID_DISPLAY

Former Member
0 Likes
773

Hello,

I use a selection screen to gather up some values, and then call FUNCTION 'REUSE_ALV_GRID_DISPLAY

I have not defined a screen for this.

When the grid is displayed, it is displayed, about a quarter of the screen down.

Is there a way to correct this, or specify the co-ordinates of the grid when makeing the call to this function?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
726

Sims, this should be displaying in full screen mode. Can you post the code, so that I can check in my system?

Regards,

Rich Heilman

5 REPLIES 5
Read only

Former Member
0 Likes
726

If you define a screen for it, and set the container for it at the top, you should be fine. You have to make some modifications in that case, but check to bcalv_edit_01 through bcalv_edit_08 programs for helpful code.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
727

Sims, this should be displaying in full screen mode. Can you post the code, so that I can check in my system?

Regards,

Rich Heilman

Read only

0 Likes
726

Hi Rich,

the code is below:

REPORT zSims LINE-SIZE 250.

  • no standard page heading.

TYPE-POOLS: slis.

*----


  • Tables Definition

*----


TABLES: ekko,

ekpo,

eket,

ekkn,

ekbe.

*----


  • Data Definition

*----


DATA: t_ekko LIKE ekko OCCURS 0 WITH HEADER LINE,

t_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE,

t_eket LIKE eket OCCURS 0 WITH HEADER LINE,

t_ekkn LIKE ekkn OCCURS 0 WITH HEADER LINE,

t_ekbe LIKE ekbe OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF w_alv,

dummy(1),

ebeln LIKE ekko-ebeln,

ebelp LIKE ekpo-ebelp,

eindt LIKE eket-eindt,

txz01 LIKE ekpo-txz01,

netwr LIKE ekpo-netwr,

sakto LIKE ekkn-sakto,

kostl LIKE ekkn-kostl,

projn LIKE ekkn-projn,

anln1 LIKE ekkn-anln1,

aufnr LIKE ekkn-aufnr,

END OF w_alv.

DATA: t_alv LIKE w_alv OCCURS 0 WITH HEADER LINE,

wa_alv LIKE w_alv, wa1_alv LIKE wa_alv,

amount TYPE currency, items LIKE sy-tabix.

DATA: i_msgid LIKE sy-msgid,

i_msgno LIKE sy-msgno,

i_msgty LIKE sy-msgty,

i_msgv1 LIKE sy-msgv1,

i_msgv2 LIKE sy-msgv2,

i_msgv3 LIKE sy-msgv3,

i_msgv4 LIKE sy-msgv4,

i_subrc LIKE sy-subrc.

DATA: ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE,

fttax LIKE fttax OCCURS 1 WITH HEADER LINE,

blntab LIKE blntab OCCURS 1 WITH HEADER LINE,

datep LIKE sy-datum.

DATA mylayout TYPE slis_layout_alv.

*variable for Report ID

DATA: v_repid LIKE sy-repid .

DATA: w_sel(1).

INCLUDE <icon>.

*declaration for fieldcatalog

DATA: i_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv.

DATA: it_listheader TYPE slis_t_listheader.

  • declaration for events table where user comand or set PF status will

  • be defined

DATA: v_events TYPE slis_t_event,

wa_event TYPE slis_alv_event.

  • declartion for layout

DATA: alv_layout TYPE slis_layout_alv.

  • declaration for variant(type of display we want)

DATA: i_variant TYPE disvariant,

i_variant1 TYPE disvariant,

i_save(1) TYPE c.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed

DATA: i_title TYPE lvc_title VALUE 'Accrual List'.

*

*----


  • Constants definition

*----


*constants: c_width type i value 172.

*

*----


  • Select Options and Parameters

*----


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

SELECT-OPTIONS: s_ebeln FOR ekko-ebeln,

s_bedat FOR ekko-bedat,

s_eindt FOR eket-eindt,

s_sakto FOR ekkn-sakto,

s_kostl FOR ekkn-kostl,

s_projn FOR ekkn-projn,

s_anln1 FOR ekkn-anln1,

s_aufnr FOR ekkn-aufnr.

SELECTION-SCREEN END OF BLOCK 1.

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

PARAMETERS:

p_post AS CHECKBOX, "Check Box To indicate Post

p_ppdat LIKE sy-datum, "Posting Date

p_redat LIKE sy-datum, "Reversal Date

p_reaso TYPE char2, "Reversal Reason

p_accru LIKE ekkn-sakto, "Accrual Account

p_doctpe LIKE bkpf-blart , "Document Type

p_ccode LIKE bkpf-bukrs, "Company Code

p_docdte LIKE sy-datum, "Document Date

p_dtxcd LIKE bseg-mwskz, "Default Tax Code

p_ref LIKE bkpf-xblnr. "Reference Text

SELECTION-SCREEN END OF BLOCK 2.

*----


  • Start-Of-Selection

*----


START-OF-SELECTION.

PERFORM do_rep.

----


  • FORM do_rep *

----


  • ........ *

----


FORM do_rep.

IF p_post = 'X'.

IF p_ppdat IS INITIAL OR p_redat IS INITIAL

OR p_reaso IS INITIAL OR p_accru IS INITIAL

OR p_doctpe IS INITIAL OR p_ccode IS INITIAL

OR p_docdte IS INITIAL OR p_dtxcd IS INITIAL

OR p_ref IS INITIAL.

CALL FUNCTION 'POPUP_FOR_INTERACTION'

EXPORTING

headline = 'Posting Accruals'

text1 = 'When Posting Accruals, Parameters Below'

text2 = 'Check Box Must Be Supplied.'

  • TEXT3 = ' '

  • TEXT4 = ' '

  • TEXT5 = ' '

  • TEXT6 = ' '

ticon = 'I'

button_1 = 'OK'

  • BUTTON_2 = ' '

  • BUTTON_3 = ' '

  • IMPORTING

  • BUTTON_PRESSED =

.

EXIT.

ENDIF.

ENDIF.

SELECT * FROM ekko INTO TABLE t_ekko

WHERE ebeln IN s_ebeln

AND bedat IN s_bedat.

REFRESH t_ekpo.

LOOP AT t_ekko.

SELECT * FROM ekpo APPENDING TABLE t_ekpo

WHERE ebeln EQ t_ekko-ebeln.

ENDLOOP.

LOOP AT t_ekpo.

SELECT * FROM eket APPENDING TABLE t_eket

WHERE ebeln EQ t_ekpo-ebeln

AND ebelp EQ t_ekpo-ebelp

AND eindt IN s_eindt.

ENDLOOP.

LOOP AT t_eket.

SELECT * FROM ekkn

WHERE ebeln EQ t_eket-ebeln

AND ebelp EQ t_eket-ebelp

AND sakto IN s_sakto

AND kostl IN s_kostl

AND projn IN s_projn

AND anln1 IN s_anln1

AND aufnr IN s_aufnr.

READ TABLE t_ekpo WITH KEY ebeln = t_eket-ebeln

ebelp = t_eket-ebelp.

  • write: / w_sel as checkbox,

  • t_eket-ebeln,

  • t_eket-ebelp,

  • t_eket-eindt,

  • t_ekpo-txz01,

  • t_ekpo-netwr,

  • ekkn-sakto,

  • ekkn-kostl,

  • ekkn-projn,

  • ekkn-anln1,

  • ekkn-aufnr.

CLEAR t_alv.

MOVE-CORRESPONDING ekkn TO t_alv.

MOVE-CORRESPONDING t_eket TO t_alv.

MOVE-CORRESPONDING t_ekpo TO t_alv.

SELECT * FROM ekbe

WHERE ebeln EQ t_eket-ebeln

AND ebelp EQ t_eket-ebelp

AND bewtp EQ 'E'.

IF ekbe-shkzg EQ 'S'.

t_alv-netwr = t_alv-netwr - ekbe-wrbtr.

ELSE.

t_alv-netwr = t_alv-netwr + ekbe-wrbtr.

ENDIF.

ENDSELECT.

APPEND t_alv.

ENDSELECT.

ENDLOOP.

  • uline.

  • write: / icon_execute_object as icon,

  • 'Create Accrual posting'.

PERFORM build_fieldcatlog.

v_repid = sy-repid.

mylayout-box_fieldname = 'DUMMY'.

mylayout-box_tabname = t_alv.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_pf_status_set = 'STATUS'

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

i_grid_title = i_title

  • I_GRID_SETTINGS =

is_layout = mylayout

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'ZLAY1'

i_save = 'A'

  • is_variant = i_variant

it_events = v_events

TABLES

t_outtab = t_alv

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

ENDFORM.

----


  • FORM build_fieldcatlog *

----


  • ........ *

----


FORM build_fieldcatlog.

REFRESH i_fieldcat.

"perform do_fieldcat using 'W_ALV' 'DUMMY' 'Select'.

wa_fieldcat-tabname = 'W_ALV'.

wa_fieldcat-fieldname = 'DUMMY'.

  • wa_fieldcat-seltext_m = ''. "Was 'Select'

  • wa_fieldcat-checkbox = 'X'.

wa_fieldcat-edit = 'X'.

  • APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

PERFORM do_fieldcat USING 'W_ALV' 'EBELN' 'PO Nr'.

PERFORM do_fieldcat USING 'W_ALV' 'EBELP' 'Item'.

PERFORM do_fieldcat USING 'W_ALV' 'EINDT' 'Del.Date'.

PERFORM do_fieldcat USING 'W_ALV' 'TXZ01' 'Description'.

PERFORM do_fieldcat USING 'W_ALV' 'NETWR' 'Undel.Value'.

PERFORM do_fieldcat USING 'W_ALV' 'SAKTO' 'G/L Account'.

PERFORM do_fieldcat USING 'W_ALV' 'KOSTL' 'Cost Centre'.

PERFORM do_fieldcat USING 'W_ALV' 'PROJN' 'Project'.

PERFORM do_fieldcat USING 'W_ALV' 'ANLN1' 'Asset Id'.

PERFORM do_fieldcat USING 'W_ALV' 'AUFNR' 'Int. Order'.

ENDFORM.

----


  • FORM do_fieldcat *

----


  • ........ *

----


  • --> W_TABNAME *

  • --> W_FIELDNAME *

  • --> W_SELTEXT_M *

----


FORM do_fieldcat

USING w_tabname

w_fieldname

w_seltext_m.

wa_fieldcat-tabname = w_tabname.

wa_fieldcat-fieldname = w_fieldname.

wa_fieldcat-seltext_m = w_seltext_m.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

ENDFORM.

----


  • FORM user_command *

----


  • ........ *

----


  • --> P_UCOMM *

  • --> P_SELFLD *

----


FORM user_command USING p_ucomm TYPE sy-ucomm

p_selfld TYPE slis_selfield.

  • DATA ref1 TYPE REF TO cl_gui_alv_grid.

  • CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

  • IMPORTING

  • e_grid = ref1.

  • CALL METHOD ref1->check_changed_data.

CASE p_ucomm.

WHEN 'OKCODE'.

  • Count the number of records that need to be posted

items = 0.

LOOP AT t_alv.

IF t_alv-dummy = 'X'.

items = items + 1.

ENDIF.

ENDLOOP.

IF items > 0.

IF p_post ='X'.

PERFORM process_accruals.

ENDIF.

ENDIF.

ENDCASE.

ENDFORM.

----


  • FORM STATUS *

----


  • ........ *

----


  • --> P_EXTAB *

----


FORM status USING p_extab TYPE slis_t_extab.

*- Pf status

SET PF-STATUS 'STATUS' EXCLUDING p_extab.

ENDFORM. " STATUS

----


  • FORM top_of_page *

----


  • ........ *

----


FORM top_of_page.

ENDFORM.

----


  • FORM Process_Accruals *

----


  • ........ *

----


FORM process_accruals.

DATA: lineno LIKE sy-tabix,

myassignmnet(18) TYPE c.

  • Prodcue the first header

PERFORM create_header.

CLEAR amount.

*Line Items Now

LOOP AT t_alv.

IF t_alv-dummy = 'X'. "Selected item, needs to be Processed

lineno = lineno + 1.

READ TABLE t_alv INDEX sy-tabix INTO wa_alv.

  • 40 if positive and Not Posting to an asset, else 70

ftpost-stype ='P'. "

ftpost-count = lineno.

ftpost-fnam = 'RF05A-NEWBS' . "Constant based on type

IF wa_alv-anln1 = ''.

IF wa_alv-netwr < 0.

ftpost-fval = '50'.

ELSE.

ftpost-fval = '40'.

ENDIF.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-HKONT' .

ftpost-fval = wa_alv-sakto.

APPEND ftpost.

ELSE. "Asset Hence Posting Key 70 Transaction Type 100

ftpost-fval = '70'.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'RF05A-NEWBW' .

ftpost-fval = '100'.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-HKONT' .

ftpost-fval = wa_alv-anln1.

APPEND ftpost.

ENDIF.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-WRBTR' . "Amount in document currency

ftpost-fval = wa_alv-netwr.

CONDENSE ftpost-fval.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-MWSKZ' . "Tax on sales/purchases code

ftpost-fval = p_dtxcd .

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-ZUONR' . "Item Text

CONCATENATE wa_alv-ebeln wa_alv-ebelp INTO ftpost-fval SEPARATED

BY space. .

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-SGTXT' . "Item Text

ftpost-fval = wa_alv-txz01 .

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BDC_SUBSCR' .

ftpost-fval = 'SAPLKACB' .

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'DKACB-FMORE' .

ftpost-fval = 'X'.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'COBL-KOSTL' . "Cost Centre

ftpost-fval = wa_alv-kostl.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'COBL-FIPOS ' .

ftpost-fval = ''.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'COBL-AUFNR' .

ftpost-fval = t_alv-aufnr.

APPEND ftpost.

amount = amount + wa_alv-netwr.

ENDIF.

ENDLOOP.

  • Final Line

  • Balancing Line

lineno = lineno + 1.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'RF05A-NEWBS' .

ftpost-fval = '50' .

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'RF05A-NEWKO' .

ftpost-fval = p_accru .

APPEND ftpost.

*moved

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-WRBTR' .

CONDENSE amount.

ftpost-fval = amount.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-MWSKZ' .

ftpost-fval = p_dtxcd .

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-SGTXT' .

ftpost-fval = p_ref .

APPEND ftpost.

*Next Line

lineno = lineno + 1.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-WRBTR' .

CONDENSE amount.

ftpost-fval = amount.

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-MWSKZ' .

ftpost-fval = p_dtxcd .

APPEND ftpost.

ftpost-stype ='P'.

ftpost-count = lineno.

ftpost-fnam = 'BSEG-SGTXT' .

ftpost-fval = p_ref .

APPEND ftpost.

CALL FUNCTION 'POSTING_INTERFACE_START'

EXPORTING

i_client = sy-mandt

i_function = 'C'

i_mode = 'A'

i_update = 'S'

i_user = sy-uname

EXCEPTIONS

client_incorrect = 1

function_invalid = 2

group_name_missing = 3

mode_invalid = 4

update_invalid = 5

OTHERS = 6.

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 'POSTING_INTERFACE_DOCUMENT'

EXPORTING

i_tcode = 'FBS1'

i_sgfunct = 'C'

  • I_NO_AUTH = ' '

IMPORTING

e_msgid = i_msgid

e_msgno = i_msgno

e_msgty = i_msgty

e_msgv1 = i_msgv1

e_msgv2 = i_msgv2

e_msgv3 = i_msgv3

e_msgv4 = i_msgv4

e_subrc = i_subrc

TABLES

t_blntab = blntab

t_ftpost = ftpost

t_fttax = fttax

EXCEPTIONS

account_missing = 1

company_code_missing = 2

posting_key_invalid = 3

posting_key_missing = 4

record_type_invalid = 5

transaction_code_invalid = 6

amount_format_error = 7

too_many_line_items = 8

OTHERS = 9.

.

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 'POSTING_INTERFACE_END'

EXPORTING

i_bdcimmed = 'X'

EXCEPTIONS

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

----


  • FORM Create_Header *

----


  • Creates the Header for posting. *

----


FORM create_header.

  • header information first

ftpost-stype ='K'.

ftpost-count = 1.

ftpost-fnam = 'BKPF-BLDAT'.

WRITE p_ppdat DDMMYY TO ftpost-fval.

APPEND ftpost.

ftpost-stype ='K'.

ftpost-count = 1.

ftpost-fnam = 'BKPF-BLART'. "Document Type

ftpost-fval = p_doctpe.

APPEND ftpost.

ftpost-stype ='K'.

ftpost-count = 1.

ftpost-fnam = 'BKPF-BUKRS' . "Company Code

ftpost-fval = p_ccode .

APPEND ftpost.

ftpost-stype ='K'. "Posting date in the document

ftpost-count = 1.

ftpost-fnam = 'BKPF-BUDAT' .

WRITE p_ppdat DDMMYY TO ftpost-fval.

APPEND ftpost.

ftpost-stype ='K'. "Currency Key

ftpost-count = 1.

ftpost-fnam = 'BKPF-WAERS' .

ftpost-fval = t_ekko-waers .

APPEND ftpost.

ftpost-stype ='K'.

ftpost-count = 1.

ftpost-fnam = 'BKPF-XBLNR ' . "Reference document number ( Text )

ftpost-fval = p_ref .

APPEND ftpost.

ftpost-stype ='K'.

ftpost-count = 1.

ftpost-fnam = 'BKPF-STGRD' . "Reason for Reversal

ftpost-fval = p_reaso .

APPEND ftpost.

ftpost-stype ='K'.

ftpost-count = 1.

ftpost-fnam = 'BKPF-STODT' . "Planned Date for the Reverse Posting

WRITE p_redat DDMMYY TO ftpost-fval.

APPEND ftpost.

ftpost-stype ='K'.

ftpost-count = 1.

ftpost-fnam = 'FS006-DOCID' .

ftpost-fval = '*'.

APPEND ftpost.

  • ftpost-stype ='K'.

  • ftpost-count = 1.

  • ftpost-fnam = 'BSEG-HKONT' . "General ledger account

  • read table t_alv index 1 into wa_alv.

  • ftpost-fval = wa_alv-sakto.

  • append ftpost.

Read only

0 Likes
726

Comment the below line and test.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
  i_callback_program = v_repid
  i_callback_pf_status_set = 'STATUS'
  i_callback_user_command = 'USER_COMMAND'
*<b>i_callback_top_of_page = 'TOP_OF_PAGE'<-- this one</b>
  i_grid_title = i_title

Read only

Former Member
0 Likes
726

That should not be the case, unless you also used REUSE_ALV_COMMENTARY_WRITE for top of page and may be that is what is causing it to go down a little bit. Can you please post the call related code here?