Creating spool for ALV report in background
Hi,
Can we create a spool request if we run in background/forgorund? please help me..
I am very much thankful for your quick responses.
Yes we can create it. Execute the report in background using SM36 and then u can view the output using SM35 or the spool request number and tcode SP01.
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers
Similar Messages
-
Running ALV REPORT in background
Hi Experts ,
Before writing this query , i went through all the threads related to ALV report in background . But found none of them satisfactory .
I am running a alv report in background . I am not using OO ALV . I am using " REUSE_ALV_GRID_DISPLAY" .
This report is schedules through a background job . It is creating a spool .
But I am getting a error message : *" FRONT END NOT AVIALABLE "*
What i have found so far :
I am planning to use sy-batch variable to check whether it is running in background or not , Then I am planning to read the spool and if the spool is created , i will display the ALV .
Is this the correct approach or some other way to generate the ALV REPORT .
Also by this way will the error message *" FRONT END NOT AVIALABLE "* go .
Please advice .
Regards,
AbhishekHello Everyone ,
Thanks for your replies .
I have the spool generated . But it is waiting status .
The issue here is how I am going to say that the spool is in " Completed " status . Because only after when my spool is in completed status , I want to display the status .
Is there way for this ?
Regards ,
Abhishek -
Running the alv report in background and sending it thro email
hi,
i have to run the alv report in background and send the output through emailHi
Many a times there is a requirement to display ALV Grid (not ALV List) in the background Job. I have checked the SDN Forum for the same and it has been mentioned that ALV Grid cannot be displayed in Background, but the list output of ALV is possible. So user wont have the actual Grid interface but the List interface.
There is a workaround to display ALV Grid in Background Job. The only restriction is you cant schedule the job through SM36. You need to execute the transaction of the report program, fill in the selection screen data and hit Execute.
The job would be executed in background. User will be able to see the Job Log and Job Status after executing the program. User doesnt have to go to SM37 to view the job status/log. Once the Job Status is changed to COMPLETED, user can click on DISPLAY SPOOL to view the ALV Grid.
Limitations:
Cant schedulea background job
The session should be active until the background job is completed. If the session is closed, then user wont be able to check the output in ALV Grid. User would be able to check the output through spool or SM37
Advantages:
If the spool width is greater than 255 characters, then the entire width could be seen in the output because the output is directed to an ALV Grid and not to spool
Interface of ALV Grid is available instead of ALV List even though its a background job.
Program wont give the TIME OUT error
Steps Required:
1. Once you execute the program, the following screen would be displayed
2. Click Display Job Status to check the Status of the Background Job
3. Click on Display the Job Log to check the Log
4. Click on Display Job Status to check the Job Status
5. Click on DISPLAY SPOOL to check the spool content once the Job Status is changed to COMPLETED. Output is displayed in ALV Grid
Programs:
1. Two different programs needs to be created
ZPROGRAM_ONE: This is the 1st program, where the selection screen and all the data validations would be done. Error handling for invalid data should be done in this program.
Once the data validation is done, this program would call the 2nd program ZPROGEAM_TWO. Build the logic to display ALV Grid in this program. The logic will only display ALV in foreground and it wont be reflected in the spool.
ZPROGRAM_TWO: This program would fetch all the data and do all the processing. If you want the spool output along with ALV Grid output, then build the logic in this program to display ALV Grid.
*& Report ZPROGRAM_ONE *
REPORT zprogram_one .
PRASHANT PATIL
TABLES : mara,
tsp01.
type-pools:slis.
TYPES : BEGIN OF t_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
END OF t_mara.
DATA : i_mara TYPE STANDARD TABLE OF t_mara,
wa_mara TYPE t_mara,
wa_index TYPE indx, " For Index details
wa_index_key TYPE indx-srtfd VALUE 'PRG_ONE',
i_jobsteplist TYPE STANDARD TABLE OF tbtcstep, " For spool number
wa_params TYPE pri_params, " To Get Print Parameters
wa_jobhead TYPE tbtcjob, " To know the status of job
wa_jobsteplist TYPE tbtcstep, " To know the spool
w_jobname TYPE tbtco-jobname, " Job name for bckgrnd job
w_jobcount TYPE tbtco-jobcount, " Unique id for bckgrd job
w_path TYPE string, " Upload path
w_lsind TYPE sy-lsind, " Index
wa_seltab TYPE rsparams,
i_seltab TYPE STANDARD TABLE OF rsparams,
wa_index1 TYPE indx, " For Index details
wa_index_key1 TYPE indx-srtfd VALUE 'PRG_TWO',
i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF i_fieldcat.
CONSTANTS DECLARATION *
CONSTANTS :
c_a(1) TYPE c VALUE 'A',
c_m(1) TYPE c VALUE 'M',
c_l(1) TYPE c VALUE 'L',
c_c(1) TYPE c VALUE 'C',
c_zfdr(4) TYPE c VALUE 'ZFDR',
c_x(1) TYPE c VALUE 'X',
c_locl(4) TYPE c VALUE 'LOCL', " Destination is LOCAL
c_f(1) TYPE c VALUE 'F', " Job Status - Failed
c_s(1) TYPE c VALUE 'S',
c_p(1) TYPE c VALUE 'P'.
SELECTION SCREEN PARAMETERS
SELECT-OPTIONS : s_matnr FOR mara-matnr.
START-OF-SELECTION.
Before the export, fill the data fields before CLUSTR
wa_index-aedat = sy-datum.
wa_index-usera = sy-uname.
EXPORT s_matnr
TO DATABASE indx(st) FROM wa_index ID wa_index_key.
To Open the Job for background processing
PERFORM open_job.
To get the print parameters
PERFORM get_print_parameters.
Submit the job in background
PERFORM job_submit.
Close the background job
PERFORM job_close.
This is the output screen with the buttons ********
Create 3 buttons DISPLAY SPOOL, STATUS, JOBLOG
SET PF-STATUS 'ZS001'.
WRITE: / 'The program is submitted in Background'.
WRITE: / 'Press DISPLAY SPOOL to see the spool'.
WRITE: / 'Press STATUS to see the status of the background'.
AT USER-COMMAND.
If user presses the 'BACK' button
IF sy-ucomm = 'BAK'.
IF wa_jobhead-status = c_f OR
wa_jobhead-status = c_a.
LEAVE TO SCREEN 0.
ENDIF.
ENDIF.
If the user presses the 'DISPLAY SPOOL' Button
IF sy-ucomm = 'DISPLAY'.
PERFORM display_spool.
ENDIF.
If the user presses the 'JOB STATUS' Button
IF sy-ucomm = 'STATUS'.
PERFORM display_status.
ENDIF.
If the user presses the 'JOB LOG' Button
IF sy-ucomm = 'JOBLOG'.
PERFORM display_job_log.
ENDIF.
*& Form open_job
text
--> p1 text
<-- p2 text
FORM open_job .
This is to Create a new job which is to be submitted in background to
process sales order/delivery/invoice
Here we would get a unique id ( Jobcount ) which identifies our job
along with the job name which we have assigned to our job
CONCATENATE sy-uname
sy-datum
sy-uzeit
INTO w_jobname . " Assign unique jobname
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = w_jobname
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
jobcount = w_jobcount
CHANGING
RET =
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
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. " open_job
*& Form get_print_parameters
text
--> p1 text
<-- p2 text
FORM get_print_parameters .
DATA : l_valid TYPE c.
This is to get the Print Parameters for the job which is to be
submitted in background to process sales order/delivery/invoice
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
ARCHIVE_ID = C_CHAR_UNKNOWN
ARCHIVE_INFO = C_CHAR_UNKNOWN
ARCHIVE_MODE = C_CHAR_UNKNOWN
ARCHIVE_TEXT = C_CHAR_UNKNOWN
AR_OBJECT = C_CHAR_UNKNOWN
ARCHIVE_REPORT = C_CHAR_UNKNOWN
AUTHORITY = C_CHAR_UNKNOWN
COPIES = C_NUM3_UNKNOWN
COVER_PAGE = C_CHAR_UNKNOWN
DATA_SET = C_CHAR_UNKNOWN
DEPARTMENT = C_CHAR_UNKNOWN
destination = c_locl " LOCL
EXPIRATION = C_NUM1_UNKNOWN
immediately = space
IN_ARCHIVE_PARAMETERS = ' '
IN_PARAMETERS = ' '
LAYOUT = C_CHAR_UNKNOWN
LINE_COUNT = C_INT_UNKNOWN
LINE_SIZE = C_INT_UNKNOWN
LIST_NAME = C_CHAR_UNKNOWN
LIST_TEXT = C_CHAR_UNKNOWN
MODE = ' '
new_list_id = c_x
PROTECT_LIST = C_CHAR_UNKNOWN
no_dialog = c_x
RECEIVER = C_CHAR_UNKNOWN
RELEASE = C_CHAR_UNKNOWN
REPORT = C_CHAR_UNKNOWN
SAP_COVER_PAGE = C_CHAR_UNKNOWN
HOST_COVER_PAGE = C_CHAR_UNKNOWN
PRIORITY = C_NUM1_UNKNOWN
SAP_OBJECT = C_CHAR_UNKNOWN
TYPE = C_CHAR_UNKNOWN
user = sy-uname
USE_OLD_LAYOUT = ' '
UC_DISPLAY_MODE = C_CHAR_UNKNOWN
DRAFT = C_CHAR_UNKNOWN
ABAP_LIST = ' '
USE_ARCHIVENAME_DEF = ' '
DEFAULT_SPOOL_SIZE = C_CHAR_UNKNOWN
PO_FAX_STORE = ' '
NO_FRAMES = C_CHAR_UNKNOWN
IMPORTING
OUT_ARCHIVE_PARAMETERS =
out_parameters = wa_params
valid = l_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4
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. " get_print_parameters
*& Form job_submit
text
--> p1 text
<-- p2 text
FORM job_submit .
The job which we have created & the unique id ( jobcount ) which we
have got identifies our job. Hence those parameters are passed along
with the name of the background program "ZPROGRAM_TWO"
The job is submitted in background.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
ARCPARAMS =
authcknam = sy-uname
COMMANDNAME = ' '
OPERATINGSYSTEM = ' '
EXTPGM_NAME = ' '
EXTPGM_PARAM = ' '
EXTPGM_SET_TRACE_ON = ' '
EXTPGM_STDERR_IN_JOBLOG = 'X'
EXTPGM_STDOUT_IN_JOBLOG = 'X'
EXTPGM_SYSTEM = ' '
EXTPGM_RFCDEST = ' '
EXTPGM_WAIT_FOR_TERMINATION = 'X'
jobcount = w_jobcount
jobname = w_jobname
LANGUAGE = SY-LANGU
priparams = wa_params
report = 'ZPROGRAM_TWO'
VARIANT = ' '
IMPORTING
STEP_NUMBER =
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10
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. " job_submit
*& Form job_close
text
--> p1 text
<-- p2 text
FORM job_close .
Once the job is submitted in background then the job is closed
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = w_jobcount
jobname = w_jobname
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
strtimmed = c_x
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ =
TARGETSERVER = ' '
DONT_RELEASE = ' '
TARGETGROUP = ' '
DIRECT_START =
IMPORTING
JOB_WAS_RELEASED =
CHANGING
RET =
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 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.
ENDFORM. " job_close
*& Form display_spool
text
--> p1 text
<-- p2 text
FORM display_spool .
To Read the Job to get the spool details
DATA : l_rqident TYPE tsp01-rqident, " Spool Number
l_spoolno TYPE tsp01_sp0r-rqid_char.
CLEAR : l_rqident,
w_lsind,
wa_jobsteplist.
REFRESH : i_jobsteplist.
SET PF-STATUS 'ZAR02'.
Get the Spool Number
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '20'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Read the Job Step list to get the spool number
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
Spool Number
l_rqident = wa_jobsteplist-listident.
MOVE l_rqident TO l_spoolno.
Check the spool in TSP01
SELECT SINGLE * FROM tsp01 WHERE rqident = l_rqident.
IF sy-subrc = 0.
LEAVE TO LIST-PROCESSING.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = l_spoolno
IMPORTING
RC =
STATUS =
PERFORM show_alv.
ENDIF.
w_lsind = sy-lsind.
IF sy-lsind GE 19.
sy-lsind = 1.
ENDIF.
ENDFORM. " display_spool
*& Form show_alv
text
--> p1 text
<-- p2 text
FORM show_alv .
Before the import, fill the data fields before CLUSTR.
wa_index1-aedat = sy-datum.
wa_index1-usera = sy-uname.
To Import the selection screen data from Calling Program
IMPORT i_mara
FROM DATABASE indx(st) ID wa_index_key1 TO wa_index1.
FREE MEMORY ID wa_index_key1.
This prepares the field-catalog for ALV.
PERFORM prepare_fieldcatalog.
This displays the output in ALV format .
PERFORM display_alv.
ENDFORM. " show_alv
*& Form display_status
text
--> p1 text
<-- p2 text
FORM display_status .
To Display the STATUS of the JOB which is exectued in background
CLEAR : wa_jobsteplist.
REFRESH : i_jobsteplist.
WRITE:/ 'DISPLAYING JOB STATUS'.
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '20'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
To Display the status text as per the status type
CASE wa_jobhead-status.
WHEN 'S'. WRITE: / 'Scheduled'.
WHEN 'R'. WRITE: / 'Released'.
WHEN 'F'. WRITE: / 'Completed'.
WHEN 'A'. WRITE: / 'Cancelled'.
WHEN OTHERS.
ENDCASE.
IF sy-lsind GE 19.
sy-lsind = 1.
ENDIF.
ENDFORM. " display_status
*& Form display_job_log
text
--> p1 text
<-- p2 text
FORM display_job_log .
To display the log of the background program
LEAVE TO LIST-PROCESSING.
CALL FUNCTION 'BP_JOBLOG_SHOW_SM37B'
EXPORTING
client = sy-mandt
jobcount = w_jobcount
joblogid = ' '
jobname = w_jobname
EXCEPTIONS
error_reading_jobdata = 1
error_reading_joblog_data = 2
jobcount_missing = 3
joblog_does_not_exist = 4
joblog_is_empty = 5
joblog_show_canceled = 6
jobname_missing = 7
job_does_not_exist = 8
no_joblog_there_yet = 9
no_show_privilege_given = 10
OTHERS = 11.
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. " display_job_log
*& Form prepare_fieldcatalog
text
--> p1 text
<-- p2 text
FORM prepare_fieldcatalog .
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = 'Material no.'.
wa_fieldcat-outputlen = '18'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = 'Creation date'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = 'Name of Person'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LAEDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-reptext_ddic = ' Last Change'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " prepare_fieldcatalog
*& Form display_alv
text
--> p1 text
<-- p2 text
FORM display_alv .
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = i_fieldcat
tables
t_outtab = i_mara.
ENDFORM. " display_alv
ZPROGRAM_TWO: This is the 2nd program which would be called from program ZPROGRAM_ONE.
*& Report ZPROGRAM_TWO *
REPORT zprogram_two .
PRASHANT PATIL
TABLES : mara.
TYPE-POOLS:slis.
TYPES : BEGIN OF t_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
END OF t_mara.
DATA : i_mara TYPE STANDARD TABLE OF t_mara,
wa_mara TYPE t_mara,
wa_index TYPE indx, " For Index details
wa_index_key TYPE indx-srtfd VALUE 'PRG_ONE',
wa_index1 TYPE indx, " For Index details
wa_index_key1 TYPE indx-srtfd VALUE 'PRG_TWO',
i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF i_fieldcat.
SELECT-OPTIONS : s_matnr FOR mara-matnr.
Before the import, fill the data fields before CLUSTR.
wa_index-aedat = sy-datum.
wa_index-usera = sy-uname.
To Import the selection screen data from Calling Program
IMPORT s_matnr
FROM DATABASE indx(st) ID wa_index_key TO wa_index.
FREE MEMORY ID wa_index_key.
SELECT matnr
ersda
ernam
laeda
FROM mara
INTO TABLE i_mara
WHERE matnr IN s_matnr.
PERFORM prepare_fieldcatalog.
PERFORM display_alv.
Before the export, fill the data fields before CLUSTR
wa_index1-aedat = sy-datum.
wa_index1-usera = sy-uname.
EXPORT i_mara
TO DATABASE indx(st) FROM wa_index1 ID wa_index_key1.
*& Form prepare_fieldcatalog
text
--> p1 text
<-- p2 text
FORM prepare_fieldcatalog .
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '18'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LAEDA'.
wa_fieldcat-tabname = 'I_MARA'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " prepare_fieldcatalog
*& Form display_alv
text
--> p1 text
<-- p2 text
FORM display_alv .
Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = i_fieldcat
TABLES
t_outtab = i_mara.
ENDFORM. " display_alv
its possible to display ALV Grid using OO ALV. Following code can be used instead of FM.
In the PBO, add following code
SET PF-STATUS 'ZSTAT'.
If program is executed in background
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING
e_offline = off.
IF off IS INITIAL.
IF container1 IS INITIAL.
CREATE OBJECT container1
EXPORTING
container_name = 'CC_ALV1' .
ENDIF.
ENDIF.
CREATE OBJECT g_grid1
EXPORTING
i_parent = container1.
CALL METHOD g_grid1->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
i_save = 'A'
i_default = ' '
is_layout =
is_print =
IT_SPECIAL_GROUPS =
it_toolbar_excluding =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = i_output
it_fieldcatalog = i_fieldcatalog
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Reward points if useful
Regards
Anji -
How to submit a ALV report in background
Can you provide a peice of code to submit an ALV report in background?
and is it possible to provide a header information dynmically, (changing when we say page down) in ALV?Hello,
you can submit in background as a normal report.
If you want to get the header informations. Handle through events. Events can be handle through registring the Event handler method.
Eg:
Events
CREATE OBJECT eventhandler_object.
register eventhandler
SET HANDLER eventhandler_object->handle_print_top_of_list
FOR g_o_grid.
CALL METHOD g_o_grid->set_table_for_first_display
Reward if helps.
Thanks,
KrishnaKumar -
Can somebody give some real time questions for alv report
hi guru
can somebody give some real time questions for alv report.
answers also.
regards
subhasis.hi,
The ALV is a set of function modules and classes and their methods which are added to program code. Developers can use the functionality of the ALV in creating new reports, saving time which might otherwise have been spent on report enhancement
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. <b>To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).</b>
Using ALV, we can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
<b>Reward useful points</b>
Siva -
Create a Procedural ALV Report with editable fields and save the changes
Hi,
I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
BCALV_TEST_GRID_EDIT_01
BCALV_TEST_GRID_EDIT_02
BCALV_TEST_GRID_EDIT_04_FORMS
BCALV_TEST_GRID_EDITABLE
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_EDIT_05
BCALV_EDIT_06
BCALV_EDIT_07
BCALV_EDIT_08
BCALV_FULLSCREEN_GRID_EDIT
But all these are using OO Concepts.
Please help.
Regards,
SmruthiTABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-edit = 'X'
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-info_fieldname = 'LINE_COLOR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_pf_status_set = 'STATUS'
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
LOOP AT it_ekko INTO wa_ekko.
ld_color = ld_color + 1.
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL
FORM top-of-page *
FORM top-of-page.
WRITE:/ 'This is First Line of the Page'.
ENDFORM.
FORM status *
FORM status USING rt_extab TYPE slis_t_extab. .
SET PF-STATUS 'ALV'.
ENDFORM.
FORM USER_COMMAND *
--> RF_UCOMM *
--> RS *
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs 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 rf_ucomm.
when 'SAVE'.
get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
endcase.
endform.
ENDFORM.
here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
create a custom PF status and create push buttons and assign your ok codes in your PF status.
if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
Hope this will help you.
Regards,
phani. -
How to create an interactive alv report in which some parameters
hi all,
i want to create an interactive alv report in which some parameters in selection screen
& when fill those & press f8 then an alv list display will show & when user double click on
any row then those contents get shown in header details of module pool program which call by
tcode mentioned in same alv .And same an interactive alv report used for change & display.
please help me give me some code same as required above.
ketan
abap consultant.
Edited by: ketan pande on Feb 14, 2009 6:09 AMHi Ketan,
Please find Sample Code.
TYPE-POOLS:slis.
DATA:
w_carrid TYPE scarr-carrid,
it_fieldcat TYPE slis_t_fieldcat_alv,
fs_fieldcat LIKE LINE OF it_fieldcat,
it_eventcat TYPE slis_t_event,
fs_eventcat LIKE LINE OF it_fieldcat.
DATA:
t_spfli LIKE STANDARD TABLE OF spfli,
fs_spfli LIKE LINE OF t_spfli,
t_sflight LIKE STANDARD TABLE OF sflight,
fs_sflight LIKE LINE OF t_sflight.
SELECT-OPTIONS:
s_carrid FOR w_carrid.
START-OF-SELECTION.
SELECT * FROM spfli INTO TABLE t_spfli WHERE carrid IN s_carrid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'PICK'
i_structure_name = 'SPFLI'
TABLES
t_outtab = t_spfli
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.
*& Form PICK
FORM pick USING command LIKE sy-ucomm
selfield TYPE slis_selfield.
READ TABLE t_spfli INTO fs_spfli INDEX selfield-tabindex.
CASE command.
WHEN '&IC1'.
SELECT * FROM sflight
INTO TABLE t_sflight
WHERE carrid = fs_spfli-carrid
and connid = fs_spfli-connid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
I_INTERNAL_TABNAME =
i_structure_name = 'SFLIGHT'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = it_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
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_eventcat
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
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_sflight
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.
ENDCASE.
ENDFORM. "pick
Hope this will Be Helpful
Thanks
Kalyan -
Is it possible to run ALV report in background if Yes how?
is it possible to run ALV report in background if Yes how?
Hi,
Why not?Through se38 only you create ALV report. there you can give your report name and go to program on menu bar - click - execute buton- click-Background . You will get new screen there you can choose Execute immediate or schedule.
<REMOVED BY MODERATOR>
Cheers,
Chandra Sekhar.
Edited by: Alvaro Tejada Galindo on Mar 4, 2008 2:12 PM -
Scheduling of ALV Reports in Background
I have schedule a Report in the Back ground and also entered the spool list so that the mail can be sent to the said users but when the Report is recvd in the mail box it is recvd as html and there are many columnns in my report that are not visible.
can i schedule the report and send the report as an excel attchement in the background processing if so then how can i do that
you early reponse will be appreciated
abhishekHi,
Once you schedule the ALV report in background you will not get the entire list as it is. The output lenght of the ist generated in the background is set to 255 characters and generally data exceeding this lenght will be turncated.
You cannot download a report in excel in background. The FM's GUI_download will not work in backgorund. You will have to write the data on the application server and then write an additional program to read that data or alternatively use some of the std tcodes to fetch that data to the presentation system.
CHeers
VJ -
hi
I need to create spool after ALV display. I used this fn module RSPO_OPEN_SPOOLREQUEST and pass only the destination parameter - 'LP01'.
Spool erquest is created but no pages.. Pages 0.. Pls advise if there is any other parameter I need to fill for this fn module or any other way to achieve this.
Thanks
Arunachala.GHello Arunachala,
Please use the below steps :
1.>
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-box_fieldname = 'CHK'.
gd_layout-box_tabname = 'IT_SPOOL'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform.
2.> call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_interface_check = ' '
i_callback_program = gd_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_top_of_page = ''
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups =
IT_EVENTS =
i_save = 'X'
is_variant =
tables
t_outtab = it_spool[].
3. >Function :RSPO_OUTPUT_SPOOL_REQUEST
exporting
spool_request_id = ls_spool_id-id.
NB: data : ls_spool_id type sp01r_id,
Please try to do like this...
Any problem you have then please ask me...and tell me your task in details...and program also...what you have done..
Regards,
sujeet -
Send some sample program for ALV reports
Hi all ,
send some sample program for ALV reports for learing purpose
tahnks.Hi ,
Resource Master
Program YPPCRR *
Program type Report Program *
Title Resource Master Dara for Updation *
Author Naga Raju *
Requested By Balaji *
Date Written 24.05.2007 *
Specification Id F2-DP-FS-2-0002 *
Transport Request *
On-line Documentation
Description
This Program updates the Location Mater through the Transaction
/SAPAPO/LOC3 Based on the User Selection
Update
Reset
No Action
Output
ALV List output of the main Program
ALV List output of the Error Log
REPORT YPPCRR NO STANDARD PAGE HEADING
LINE-SIZE 120
LINE-COUNT 62(4)
MESSAGE-ID yap..
Global data
Include where all the data declarations are coded.
INCLUDE YPPCRR_data.
*Initialization
INITIALIZATION.
perform init_variant.
Constants
CONSTANTS: c_formname_top_of_page TYPE slis_formname
VALUE 'F_TOP_OF_PAGE'.
Selection-Screen
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-040.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:p_prs RADIOBUTTON GROUP ztyp USER-COMMAND ucom DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(28) text-003.
position 40.
parameters: p_file1 TYPE rlgrap-filename.
SELECTION-SCREEN END OF LINE.
skip 5.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_aps RADIOBUTTON GROUP ztyp.
SELECTION-SCREEN COMMENT 3(28) text-004.
position 40.
parameters: p_file2 type rlgrap-filename.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
DYNPRO_NUMBER = SYST-DYNNR
field_name = p_file1
STATIC = ' '
MASK = ' '
CHANGING
file_name = p_file1
EXCEPTIONS
MASK_TOO_LONG = 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.
START-OF-SELECTION.
if p_prs = 'X'.
PERFORM f_read_datum1 TABLES t_res_head
USING p_file1
CHANGING w_subrc.
elseif p_aps = 'X'.
PERFORM f_read_datum2 TABLES t_res_head
USING p_file2
CHANGING w_subrc.
endif.
IF w_subrc = 0.
Validations
PERFORM VALIDATION.
PERFORM display_alv.
IF SY-UCOMM = '&F03'
or SY-UCOMM = '&F12'
or SY-UCOMM = '&F15'.
LEAVE LIST-PROCESSING.
ELSE.
ENDIF.
ELSE.
Message s100 with text-002.
ENDIF.
END-OF-SELECTION.
Forms part*
INCLUDE YPPCRR_forms.
*& Include YPPCRR_DATA
Type-Pools
TYPE-POOLS: slis.
*TYPES
DATA: BEGIN OF tl_res_head.
INCLUDE STRUCTURE ypp_res_head.
DATA: END OF tl_res_head.
DATA: BEGIN OF tl_res_head_val.
INCLUDE STRUCTURE ypp_resv.
DATA: END OF tl_res_head_val.
DATA : BEGIN OF ty_errlog ,
counter type i,
type(2) ,
name(10) TYPE c,
vrsioid(22) TYPE c,
restype TYPE c,
message(80) TYPE c,
END OF ty_errlog.
Global Variables
DATA : gc_flag(1) TYPE c,
w_val_err_flag(1) type c.
DATA: w_filename TYPE rlgrap-filename,
w_subrc TYPE sy-subrc,
w_t_res_head TYPE slis_t_fieldcat_alv,
wa_t_res_head TYPE slis_fieldcat_alv.
DATA : wa_date(10) TYPE c,
wa_time(10) TYPE c,
wa_title(40) TYPE c,
wa_type(4) TYPE c .
DATA: BAPI_RUN_YES_NO TYPE C.
*Structure
*INTERNAL TABLES USED BY ALV
DATA:
it_fieldcat_alv TYPE slis_t_fieldcat_alv,
IT_FIELDCAT_ALV_ERR TYPE SLIS_T_FIELDCAT_ALV,
it_status TYPE slis_formname VALUE 'F_MAIN',
it_user_command TYPE slis_formname VALUE 'F_USER_COMMAND',
it_events TYPE slis_t_event,
it_event_exit TYPE slis_t_event_exit,
it_list_comments TYPE slis_t_listheader,
it_excluding TYPE slis_t_extab,
it_sort TYPE slis_t_sortinfo_alv.
*Internal Table Declarations
DATA : BEGIN OF t_imex OCCURS 0 ,
string(256) TYPE c,
END OF t_imex.
DATA : fcode TYPE TABLE OF sy-ucomm.
DATA : fcode_bdc TYPE TABLE OF sy-ucomm.
DATA : fcode_error TYPE TABLE OF sy-ucomm.
DATA : fcode_final TYPE TABLE OF sy-ucomm.
STRUCTURE and WORKARES
*Internal Table Declarations
DATA : t_res_head like tl_res_head occurs 0 WITH HEADER LINE.
DATA : t_res_head_val like tl_res_head_val occurs 0 with header line.
data :l_res_head LIKE LINE OF t_res_head.
DATA : w_file TYPE string.
*DATA : wa_vrsioid(22) type c,
wa_locno(20) type c,
wa_calendar(2) type c,
wa_planner(3) type c.
DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: RESOURCE_HEAD LIKE BAPI10004RESHEAD OCCURS 0 WITH HEADER LINE,
RESOURCE_HEAD_X LIKE BAPI10004RESHEADX OCCURS 0 WITH HEADER LINE,
RESOURCE_TEXT LIKE BAPI10004RESTEXT OCCURS 0 WITH HEADER LINE,
RESOURCE_TEXT_X LIKE BAPI10004RESTEXTX OCCURS 0 WITH HEADER LINE.
data : t_errlog like ty_errlog occurs 0 with header line.
DATA : wk_lines TYPE i,
wk_errlines TYPE i,
wk_count TYPE i.
DATA: g_tabname TYPE slis_tabname VALUE 'T_RES_HEAD'.
Variables to be used by ALV
DATA:
wk_variant LIKE disvariant,
wx_variant LIKE disvariant,
wk_variant_save(1) TYPE c,
wk_exit(1) TYPE c,
wk_repid LIKE sy-repid,
wk_user_specific(1) TYPE c,
wk_callback_ucomm TYPE slis_formname,
wk_callback_status TYPE slis_formname,
wk_callback_status1 TYPE slis_formname,
wk_print TYPE slis_print_alv,
wk_layout TYPE slis_layout_alv,
wk_html_top_of_page TYPE slis_formname,
wk_fieldcat_alv LIKE LINE OF it_fieldcat_alv,
wk_excluding LIKE LINE OF it_excluding,
wk_events LIKE LINE OF it_events,
wk_event_exit LIKE LINE OF it_event_exit,
wk_list_comments LIKE LINE OF it_list_comments,
wk_list1_comments LIKE LINE OF it_list_comments,
wk_list2_comments LIKE LINE OF it_list_comments,
wk_sort LIKE LINE OF it_sort.
*DATA :gc_delete_flag(1).
*& Include YAPOLOC_FORMS
FORM display_alv .
PERFORM f_fieldcat_build.
PERFORM f_event_build.
PERFORM f_exclude_build.
PERFORM f_print_build.
PERFORM f_layout_build.
PERFORM f_display_data.
ENDFORM. " display_alv
*& Form f_fieldcat_build
text
FORM f_fieldcat_build .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = wk_repid
i_structure_name = 'YPP_RESV'
i_inclname = wk_repid
CHANGING
ct_fieldcat = it_fieldcat_alv.
ENDFORM. " F_FIELDCAT_BUILD
*& Form F_EVENT_BUILD
text
> p1 text* < p2 text
FORM f_event_build .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events.
READ TABLE it_events WITH KEY
name = slis_ev_top_of_page INTO wk_events.
IF sy-subrc = 0.
MOVE c_formname_top_of_page TO wk_events-form.
MODIFY it_events FROM wk_events INDEX sy-tabix.
ENDIF.
ENDFORM. " F_EVENT_BUILD
*& Form F_EXCLUDE_BUILD
text
--> p1 text
<-- p2 text
FORM f_exclude_build .
wk_excluding = '&GRAPH'. "Graphic
APPEND wk_excluding TO it_excluding.
ENDFORM. " F_EXCLUDE_BUILD
*& Form F_PRINT_BUILD
text
--> p1 text
<-- p2 text
FORM f_print_build .
wk_print-no_print_listinfos = 'X'.
ENDFORM. " F_PRINT_BUILD
*& Form F_LAYOUT_BUILD
text
--> p1 text
<-- p2 text
FORM f_layout_build .
wk_layout-zebra = 'X'.
WK_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
wk_layout-detail_popup = 'X'.
wk_layout-detail_initial_lines = 'X'.
wk_layout-detail_titlebar = 'Details '.
ENDFORM. " F_LAYOUT_BUILD
*& Form F_DISPLAY_DATA
text
--> p1 text
<-- p2 text
FORM f_display_data .
wk_callback_ucomm = 'CALLBACK_UCOMM'.
IF sy-ucomm = 'UPD' OR sy-ucomm = space .
wk_callback_status = 'CALLBACK_STATUS'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_background_id = 'SIWB_WALLPAPER'
i_callback_program = wk_repid
i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
i_callback_pf_status_set = wk_callback_status
i_callback_user_command = wk_callback_ucomm
it_sort = it_sort
i_default = 'X'
i_save = 'A'
is_variant = wk_variant
is_layout = wk_layout
it_fieldcat = it_fieldcat_alv
it_events = it_events
it_event_exit = it_event_exit
it_excluding = it_excluding
is_print = wk_print
TABLES
t_outtab = t_res_head_val.
ENDFORM. " F_DISPLAY_DATA
ALV for Error Log
*& Form display_alv_ERR
text
--> p1 text
<-- p2 text
FORM display_alv_err .
PERFORM f_fieldcat_build_err.
PERFORM f_event_build_err.
PERFORM f_exclude_build_err.
PERFORM f_print_build_err.
PERFORM f_layout_build_err.
PERFORM f_display_data_err.
ENDFORM. " display_alv_ERR
*& Form F_FIELDCAT_BUILD_err
text
--> p1 text
<-- p2 text
FORM f_fieldcat_build_err .
BREAK-POINT.
REFRESH it_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = wk_repid
i_internal_tabname = 'TY_ERRLOG'
i_structure_name = 'YPP_ERR_LOG'
i_inclname = wk_repid
CHANGING
ct_fieldcat = it_fieldcat_alv_err.
LOOP AT it_fieldcat_alv INTO wk_fieldcat_alv.
CASE wk_fieldcat_alv-fieldname.
WHEN 'COUNTER'.
wk_fieldcat_alv-seltext_s = text-023.
wk_fieldcat_alv-seltext_m = text-023.
wk_fieldcat_alv-seltext_l = text-023.
wk_fieldcat_alv-reptext_ddic = text-023.
wk_fieldcat_alv-edit = 'X'.
WHEN 'TYPE'.
wk_fieldcat_alv-seltext_s = text-009.
wk_fieldcat_alv-seltext_m = text-009.
wk_fieldcat_alv-seltext_l = text-009.
wk_fieldcat_alv-reptext_ddic = text-009.
wk_fieldcat_alv-edit = 'X'.
WHEN 'NAME'.
wk_fieldcat_alv-seltext_s = text-010.
wk_fieldcat_alv-seltext_m = text-010.
wk_fieldcat_alv-seltext_l = text-010.
wk_fieldcat_alv-reptext_ddic = text-010.
wk_fieldcat_alv-edit = 'X'.
WHEN 'VRSIOID'.
wk_fieldcat_alv-seltext_s = text-011.
wk_fieldcat_alv-seltext_m = text-011.
wk_fieldcat_alv-seltext_l = text-011.
wk_fieldcat_alv-reptext_ddic = text-011.
wk_fieldcat_alv-edit = 'X'.
WHEN 'RESTYPE'.
wk_fieldcat_alv-seltext_s = text-012.
wk_fieldcat_alv-seltext_m = text-012.
wk_fieldcat_alv-seltext_l = text-012.
wk_fieldcat_alv-reptext_ddic = text-012.
wk_fieldcat_alv-edit = 'X'.
WHEN 'MESSAGE'.
wk_fieldcat_alv-seltext_s = text-013.
wk_fieldcat_alv-seltext_m = text-013.
wk_fieldcat_alv-seltext_l = text-013.
wk_fieldcat_alv-reptext_ddic = text-013.
wk_fieldcat_alv-edit = 'X'.
WHEN OTHERS.
ENDCASE.
MODIFY it_fieldcat_alv FROM wk_fieldcat_alv.
ENDLOOP.
ENDFORM. " F_FIELDCAT_BUILD_err
*& Form F_EVENT_BUILD_err
text
--> p1 text
<-- p2 text
FORM f_event_build_err .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events.
READ TABLE it_events WITH KEY name = slis_ev_top_of_page
INTO wk_events.
IF sy-subrc = 0.
MOVE c_formname_top_of_page TO wk_events-form.
MODIFY it_events FROM wk_events INDEX sy-tabix.
ENDIF.
ENDFORM. " F_EVENT_BUILD_err
*& Form F_EXCLUDE_BUILD_err
text
--> p1 text
<-- p2 text
FORM f_exclude_build_err .
wk_excluding = '&GRAPH'. "Graphic
APPEND wk_excluding TO it_excluding.
ENDFORM. " F_EXCLUDE_BUILD_err
*& Form F_PRINT_BUILD_err
text
--> p1 text
<-- p2 text
FORM f_print_build_err .
wk_print-no_print_listinfos = 'X'.
ENDFORM. " F_PRINT_BUILD_err
*& Form F_LAYOUT_BUILD_err
text
--> p1 text
<-- p2 text
FORM f_layout_build_err .
wk_layout-zebra = 'X'.
WK_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
wk_layout-detail_popup = 'X'.
wk_layout-detail_initial_lines = 'X'.
wk_layout-detail_titlebar = 'Details '.
ENDFORM. " F_LAYOUT_BUILD_err
*& Form F_DISPLAY_DATA_err
text
--> p1 text
<-- p2 text
FORM f_display_data_err .
wk_callback_ucomm = 'CALLBACK_UCOMM'.
IF SY-UCOMM ne '&F03'.
wk_callback_status = 'CALLBACK_STATUS'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_background_id = 'SIWB_WALLPAPER'
i_callback_program = wk_repid
i_callback_pf_status_set = wk_callback_status
i_callback_user_command = wk_callback_ucomm
it_sort = it_sort
i_default = 'X'
i_save = 'A'
is_variant = wk_variant
is_layout = wk_layout
it_fieldcat = it_fieldcat_alv_err
it_events = it_events
it_event_exit = it_event_exit
it_excluding = it_excluding
is_print = wk_print
TABLES
t_outtab = t_errlog.
KEEP EERRLOG BUTTON
SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD' IMMEDIATELY.
ENDFORM. "f_display_data_err
**& Form F_TOP_OF_PAGE
text
FORM f_top_of_page.
CLEAR: it_list_comments[],
wk_list_comments,
wk_list1_comments,
wk_list2_comments.
wk_list_comments-typ = 'H'. "H=Header,S=Selection, A=Action
wk_list_comments-key = ''.
CASE sy-ucomm.
WHEN ''.
wk_list_comments-info = text-030.
WHEN 'UPD'.
IF t_errlog[] IS INITIAL.
wk_list_comments-info = text-031.
ELSE.
wk_list_comments-info = text-032.
ENDIF.
WHEN 'ERRLOG'.
wk_list_comments-info = text-032.
WHEN '&F03'.
wk_list_comments-info = text-031.
WHEN '&F15'.
wk_list_comments-info = text-031.
WHEN '&F12'.
wk_list_comments-info = text-031.
ENDCASE.
APPEND wk_list_comments TO it_list_comments.
WRITE sy-datum TO wa_date.
WRITE sy-uzeit TO wa_time.
wk_list_comments-typ = 'S'. "H=Header, S=Selection, A=Action
wk_list_comments-key = ''.
wk_list_comments-info = 'User:'.
wk_list1_comments-info = sy-uname.
CONCATENATE wk_list_comments wk_list1_comments
INTO wk_list2_comments.
APPEND wk_list2_comments TO it_list_comments.
wk_list_comments-typ = 'S'. "H=Header, S=Selection, A=Action
wk_list_comments-key = ''.
wk_list_comments-info = ' Run Date : '.
wk_list1_comments-info = wa_date.
CONCATENATE wk_list_comments wk_list1_comments
INTO wk_list2_comments .
APPEND wk_list2_comments TO it_list_comments.
wk_list_comments-typ = 'S'. "H=Header, S=Selection, A=Action
wk_list_comments-key = ''.
wk_list_comments-info = 'Run Time : '.
wk_list1_comments-info = wa_time.
CONCATENATE wk_list_comments wk_list1_comments
INTO wk_list2_comments .
APPEND wk_list2_comments TO it_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'ENJOYSAP_LOGO'
it_list_commentary = it_list_comments.
ENDFORM. "F_TOP_OF_PAGE
FORM USER_COMMAND_SAMPLE *
--> UCOMM *
--> SELFIELD *
FORM callback_ucomm USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA: v_langu(2) ,
v_loctype TYPE /sapapo/c_loctype.
data err_flg(1).
IF bapi_run_yes_no IS INITIAL.
CASE sy-ucomm.
WHEN 'UPD'.
bapi_run_yes_no = 'X'.
LOOP AT t_res_head_val WHERE val_err_msg EQ space.
v_langu = 'EN'.
refresh tables
REFRESH : resource_head ,
resource_head_x ,
resource_text ,
resource_text_x,
t_return.
CLEAR : resource_head ,
resource_head_x ,
resource_text ,
resource_text_x,
t_return .
resource_head-resource = t_res_head-name .
resource_head-restype = t_res_head-restype.
resource_head-location = t_res_head-locno.
CLEAR : v_loctype .
SELECT SINGLE loctype FROM /sapapo/loc CLIENT SPECIFIED
INTO v_loctype
WHERE mandt = sy-mandt
AND locno = t_res_head-locno.
resource_head-loctype = v_loctype.
resource_head-calendar = t_res_head-calendar.
resource_head-type = t_res_head-type.
IF t_res_head-type = '03'.
resource_head-dimension_bucket = t_res_head-dimension_bucket.
ELSE.
resource_head-dimension_bucket = space.
ENDIF.
APPEND resource_head.
CLEAR resource_head.
resource_head_x-resource = t_res_head-name.
resource_head_x-restype = 'X'.
resource_head_x-location = 'X'.
resource_head_x-loctype = 'X'.
resource_head_x-calendar = 'X'.
resource_head_x-type = 'X'.
IF t_res_head-type = '03'.
resource_head_x-dimension_bucket = 'X'.
ELSE.
resource_head_x-dimension_bucket = space.
ENDIF.
APPEND resource_head_x.
CLEAR resource_head_x.
resource_text-resource = t_res_head-name.
resource_text-langu = v_langu.
resource_text-res_short_text = t_res_head-text.
APPEND resource_text.
CLEAR resource_text.
resource_text_x-resource = t_res_head-name.
resource_text_x-langu = v_langu.
resource_text_x-res_short_text = 'X'.
APPEND resource_text_x.
CLEAR resource_text_x.
call bapi
CALL FUNCTION 'BAPI_RSSRVAPS_SAVEMULTI_30A'
EXPORTING
logical_system = 'AD2CLNT200'
business_system_group = 'BSG001'
commit_control = 'E'
NO_CREATE = ' '
TABLES
resource_head = resource_head
resource_head_x = resource_head_x
resource_text = resource_text
resource_text_x = resource_text_x
return = t_return.
IF sy-subrc = 0.
LOOP AT t_return WHERE type = 'E'
OR type = 'A'.
MOVE t_res_head_val-counter TO t_errlog-counter.
MOVE t_res_head_val-type TO t_errlog-type.
MOVE t_res_head_val-name TO t_errlog-name.
MOVE t_res_head_val-vrsioid TO t_errlog-vrsioid.
MOVE t_res_head_val-restype TO t_errlog-restype.
MOVE t_return-message TO t_errlog-message.
APPEND t_errlog.
CLEAR t_errlog..
ENDLOOP.
IF not t_errlog[] is initial..
IF sy-subrc = 0.
ERROR POP UP
MESSAGE text-007 type 'I'.
ELSE.
err_flg = 'X'.
SUCC POP UP
MESSAGE text-008 type 'I'.
ENDIF.
ELSE. "NE 0
LOOP AT t_return WHERE type = 'E'
OR type = 'A'.
MOVE t_res_head_val-counter TO t_errlog-counter.
MOVE t_res_head_val-type TO t_errlog-type.
MOVE t_res_head_val-name TO t_errlog-name.
MOVE t_res_head_val-vrsioid TO t_errlog-vrsioid.
MOVE t_res_head_val-restype TO t_errlog-restype.
MOVE t_return-message TO t_errlog-message.
APPEND t_errlog.
CLEAR t_errlog..
ENDLOOP.
IF sy-subrc = 0.
ELSE.
MOVE t_res_head_val-counter TO t_errlog-counter.
MOVE t_res_head_val-type TO t_errlog-type.
MOVE t_res_head_val-name TO t_errlog-name.
MOVE t_res_head_val-vrsioid TO t_errlog-vrsioid.
MOVE t_res_head_val-restype TO t_errlog-restype.
MOVE 'Error in Creation' TO t_errlog-message.
APPEND t_errlog.
CLEAR t_errlog..
ENDIF.
ENDIF.
ENDLOOP.
gc_flag = 'X'.
REFRESH fcode.
if err_flg = 'X'.
MESSAGE text-008 type 'I'.
endif.
ENDCASE.
ENDIF.
IF NOT t_errlog[] IS INITIAL.
wk_list_comments-info = text-032.
APPEND wk_list_comments TO it_list_comments.
APPEND 'UPD' TO fcode_error.
APPEND 'ERRLOG' TO fcode_error.
SET PF-STATUS 'ZSTANDARD' EXCLUDING fcode_error.
PERFORM display_alv_err.
ELSE.
ENDIF.
ENDFORM. "CALLBACK_UCOMM=
*& Form CALLBACK_STATUS
text
-->RT_EXTAB text
FORM callback_status USING rt_extab TYPE slis_t_extab.
IF bapi_run_yes_no IS NOT INITIAL .
IF t_errlog[] IS INITIAL.
REFRESH fcode.
APPEND 'UPD' TO fcode.
APPEND 'ERRLOG' TO fcode.
SET PF-STATUS 'ZSTANDARD' EXCLUDING 'ERRLOG'.
SET PF-STATUS 'ZSTANDARD' EXCLUDING fcode IMMEDIATELY .
ENDIF.
ELSE.
SET PF-STATUS 'ZSTANDARD' EXCLUDING 'ERRLOG' IMMEDIATELY .
ENDIF.
ENDFORM. "CALLBACK_STATUS
*& Form CALLBACK_STATUS1
text
-->RT_EXTAB text
FORM callback_status1 USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD'.
ENDFORM. " CALLBACK_STATUS
*& Form CALLBACK_STATUS2
text
-->RT_EXTAB text
FORM callback_status2 USING rt_extab TYPE slis_t_extab.
REFRESH fcode_final.
IF sy-ucomm NE '&F03'.
APPEND 'UPD' TO fcode_final.
APPEND 'ERRLOG' TO fcode_final.
SET PF-STATUS 'ZSTANDARD' EXCLUDING fcode_final.
ELSE.
SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD'.
ENDIF.
ENDFORM. "CALLBACK_STATUS2
*& Form callback_ucomm_E
text
-->UCOMM text
-->SELFIELD text
FORM callback_ucomm_e USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE sy-ucomm.
WHEN 'ERRLOG' .
PERFORM display_alv_err.
WHEN '&F03'.
SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD' IMMEDIATELY .
PERFORM display_alv .
ENDCASE.
ENDFORM. "CALLBACK_UCOMM=
*& Form init_variant
text
--> p1 text
<-- p2 text
FORM init_variant .
CLEAR: wk_variant.
wk_repid = sy-repid.
wk_variant-report = wk_repid.
wk_variant-username = sy-uname.
wk_variant_save = 'A'. "All types
ENDFORM. " init_variant
*& Form f_read_datum1
text
-->P_T_RES_HEAD text
-->P_P_FILE1 text
<--P_W_SUBRC text
FORM f_read_datum1 TABLES p_t_res_head STRUCTURE ypp_res_head
USING p_p_file1
CHANGING p_w_subrc.
DATA : iexcel LIKE zexcel_read OCCURS 0 WITH HEADER LINE.
CLEAR p_w_subrc.
CALL FUNCTION 'ZALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_p_file1
i_begin_col = 1
i_begin_row = 1
i_end_col = 62
i_end_row = 50000
TABLES
intern = iexcel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
p_w_subrc = 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT iexcel WHERE row > 2.
IF iexcel-col = '0001'.
p_t_res_head-type = iexcel-value.
ENDIF.
IF iexcel-col = '0002'.
p_t_res_head-name = iexcel-value.
ENDIF.
IF iexcel-col = '0003'.
p_t_res_head-vrsioid = iexcel-value.
ENDIF.
IF iexcel-col = '0004'.
p_t_res_head-restype = iexcel-value.
ENDIF.
IF iexcel-col = '0005'.
p_t_res_head-locno = iexcel-value.
ENDIF.
IF iexcel-col = '0006'.
p_t_res_head-tzone = iexcel-value.
ENDIF.
IF iexcel-col = '0007'.
p_t_res_head-calendar = iexcel-value.
ENDIF.
IF iexcel-col = '0008'.
p_t_res_head-planner = iexcel-value.
ENDIF.
IF iexcel-col = '0009'.
p_t_res_h -
Creation of Spool for a Report Output in background.
Hi Gurus,
I am working on a Report and my requirement is that a Spool should be Generated for the Report Output in background. Instead of generating the spool manually, I need it to be generated in background.
Please let me know ASAP.
Regards,
Amit.Get print parameters using 'GET_PRINT_PARAMETERS'.
DATA : rep LIKE pri_params-plist,
w_title TYPE tsp01-rqtitle,
mstr_print_parms LIKE pri_params.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING destination = 'LP01'
copies = 1
list_name = rep
list_text = w_title
immediately = 'X'
release = 'X'
new_list_id = 'X'
expiration = 1
line_size = 132
line_count = 65
layout = 'X_65_132'
sap_cover_page = 'X'
cover_page = ' '
receiver = sy-uname
department = 'System'
no_dialog = 'X'
IMPORTING out_parameters = mstr_print_parms
valid = mc_valid.
and then use submit statement-
SUBMIT
zp1012_ar_rep_vendstat
TO SAP-SPOOL
WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS mstr_print_parms
WITH s_lifnr IN s_lifnr
WITH p_bukrs eq p_bukrs
WITH s_gjahr eq p_gjahr SIGN 'I'
WITH s_monat BETWEEN p_per-low AND p_per-high SIGN 'I'
AND RETURN.
COMMIT WORK.
Regards,
Aparna Gaikwad -
Create spool for background jobs which uses submit statement
Hi Gurus,
I have a quick question regarding the backgroud jobs. When we run a program in the background , it should create a spool for us, but, the problem comes when I am running a program in the background, its not creating the spool. This program uses SUBMIT statement. This program collects the data and it will submit to the other program and then retuen. In this case, its not creating a spool. Its very important for us to look at the spool for this program. Does anybody cam across this kind of problem? I need ur inputs.
Thanks in advance, <REMOVED BY MODERATOR>
Regards,
Srinivas.
Edited by: Alvaro Tejada Galindo on Mar 18, 2008 4:31 PMhi check this link ...
Scheduling a submitable program as a background task with the number number in a background request name. After scheduling, the background task is completed by function module JOB_CLOSE and released immediately.
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=backgroundsubmit&adv=false&sortby=cm_rnd_rankvalue
sy-subrc Meaning
0 Background task scheduled successfully.
4 Scheduling cancelled by user on the selection screen.
8 Error during scheduling, i.e. when accessing JOB_SUBMIT internally.
12 Error in internal number assignment.
regards,
venkat.
Edited by: venkat appikonda on Mar 18, 2008 6:32 PM -
Hi,
We have an report in which we are using FM :- REUSE_ALV_LIST_DISPLAY.
In forgroud the Report Header is getting displayed only Once.
When we run the report in background, we are getting in spool in which there are "Page Break and Header" in every page.
Downloading the report to MS Excel from Spool is creating setting problem.
Please tell me "how can we do so while running the report in background, "Page break and header dosen't create i.e only One Header and One Page"
Waiting for reply..
Saurabh GargHi Saurabh ,
Use TOP-OF-LIST instead of TOP-OF-PAGE.
Please check this sample with different events in ALV-GRID.
report zbnstest.
* TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
* WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
* GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
* INTERNAL TABLE DECLARATION.
* INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
* INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
* INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
* INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
* THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
* AND THE LAYOUT FOR THE ALV.
* HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
* WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
* OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
* THIS IS DONE TO MAKE THE CODE SIMPLER.
* OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
* PROGRAMS.
* IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
* MORE TABLES AND CREATE A STRUCTURE
* IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
* LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
* DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
* TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
* DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
* STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
* INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
* START-OF-SELECTION. *
start-of-selection.
* SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
* SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
* SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
* INTERNAL TABLE.
perform selectdata_and_sort.
* SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
* SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
* SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
* SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
* SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
* FORMS
* IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
* OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
* COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
* FORM FILL_FIELDS_OF_FIELDCATALOG *
* --> FIELDCATALOG *
* --> P_TABNAME *
* --> P_FIELDNAME *
* --> P_KEY *
* --> P_KEY *
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
* p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
* FORM POPULATE_LAYOUT *
* --> FIELDLAYOUT *
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
* FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
* This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
* fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
* FORM SELECTDATA_AND_SORT *
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
* FORM MERGE_FIELDCATALOG *
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
* i_structure_name = 'COLORSTRUCT'
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
* IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
* FOLLOWS:-
* i_callback_program --> CALLING PROGRAM NAME
* i_structure_name --> STRUCTURE NAME.
* is_layout --> LAYOUT NAME.
* it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
* TOOL BAR
i_save = 'A'
* IS_VARIANT = ' '
it_events = eventstab[]
* IT_EVENT_EXIT =
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*& Form POPULATE_ITAB1
* text
* --> p1 text
* <-- p2 text
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*& Form FILL_EVENTSTAB
* text
* -->P_EVENTSTAB text *
form fill_eventstab tables p_eventstab structure eventstab.
* WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
* INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
* AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
* EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
* BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
* THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
* WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
* FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
* IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
*& Form FILL_HEADINGTABLE
* text
* -->P_HEADING text *
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
* WHEN 'HEADING5'.
* P_HEADING-TYP = 'H'.
* P_HEADING-INFO = 'LIST-MODIFY'.
* APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
*& Form FILL_COLORSTRUCT
* text
* -->P_COLORSTRUCT text *
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
* FORM TOP_OF_COVERPAGE *
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
* FORM END_OF_COVERPAGE *
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
* FORM FOREIGN_TOP_OF_PAGE *
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
* FORM FOREIGN_END_OF_PAGE *
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
* FORM LIST_MODIFY *
*FORM LIST_MODIFY.
* CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
* EXPORTING
* IT_LIST_COMMENTARY = HEADING5[]
* EXCEPTIONS
* OTHERS = 1.
*ENDFORM.
* FORM END_OF_PAGE *
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
* FORM END_OF_LIST *
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
* FORM TOP_OF_LIST *
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Regards,
Raghav -
I have a ALV report output with LINE-SIZE 1023. But when I try to execute the report in background the output row is not coming in one line but in 2 lines. When we run the report in background I gave the printer as 'LOCL' (local) and displayed in spool. In the PRINT SETTINGS I don't see FORMAT for 65 X 1023. Do I need to create one? If yes, how to create it? Or if there is any other way go get all the cloumns in one row of a ALV output.
Thank you.Hi,
<b>Change the font on the X_65_255 paper size :-</b>
This tip was taken from the SAP-R3 mailing list, <b>and is by Sheila Tichener</b>.
If you need to use a large line-size to get all your data in I know the sap version of X_65_255 for hp laser jet 4 gives an unnecessarily small font . You can change it in SPAD (or copy to Y_65_255) as follows.
<b>Example:</b>
Choose Device formats, Change
hplj4
x_65_255
Execute
Double click on printer initialisation
Change from:-
# select Courier 16.67 CPI normal font
e(s0p16.67h0s0b4099T
to:-
# select arial 24 cpi 15 point normal
e(s0p24h15v0s0b16602T
Also bold as follows:-
# select arial 24 cpi 15 point bold
e(s0p24h15v0s3b16602T
Also the error you get when changing a format in the output screen is only a warning and can be overidden by pressing the green tick.
If the sap standard formats don't fit your requirements you can create your own eg Y_65_170 . It seems to be the numbers in the name that somehow triggers which one the abap chooses
Regards
Sudheer
Maybe you are looking for
-
Process Instance.Task Details.Update Date
Hi experts, Process Instance.Task Details.Update Date Process Instance.Task Information.Update Date From these two dates which one captures the approval task assignment date. For e.g. If we reassign the approval task after some idle period to another
-
I lost my LR cc when computer was crashed,
got my PS back but now want the LR too. I pay for the CC already, $9.99/mo. How?
-
Mail not updating after recent update
After the recent update my mail does not update unless I press the mail icon. In the past I would hear a sound and a number would appear next to the icon letting me know how many mails received. Any ideas?
-
My company is using Hyperion for financial management reporting and I want to know what are the reasons that demand Hyperion, why can't we use SAP SEM or SAP BCS for that purpose. I would be thankful if anyone can give me some more info. on this.
-
Installing LR 3 on new Mac Book Pro
How can I install LR 3 on my new mac book pro without a disk drive?