I am trying to display 2 row multi heading in an alv grid display where each main heading should occupy 2 sub-headings as follows:
REPORT zsam7.
TYPE-POOLS: slis. " SLIS contains all the ALV data
TYPES: BEGIN OF ty_report,
jan_deb TYPE umxxs,
jan_cred TYPE umxxh,
feb_deb TYPE umxxs,
feb_cred TYPE umxxh,
END OF ty_report,
tt_report TYPE TABLE OF ty_report.
DATA: lt_report TYPE tt_report WITH HEADER LINE,
wa TYPE ty_report,
lfc1_table TYPE STANDARD TABLE OF lfc1,
repid TYPE sy-repid,
wa_deb TYPE saldv,
wa_cred TYPE saldv,
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
x_events TYPE slis_alv_event,
it_events TYPE slis_t_event,
l_layout TYPE slis_layout_alv.
FIELD-SYMBOLS: <fs_rep> LIKE LINE OF lt_report,
<fs_rep1> LIKE LINE OF lfc1_table.
SELECT * FROM lfc1 INTO CORRESPONDING FIELDS OF TABLE lfc1_table WHERE bukrs = '1000' AND gjahr = 2003.
LOOP AT lfc1_table ASSIGNING <fs_rep1>.
APPEND INITIAL LINE TO lt_report ASSIGNING <fs_rep>.
IF <fs_rep1>-um01s > <fs_rep1>-um01h.
<fs_rep>-jan_deb = <fs_rep1>-um01s - <fs_rep1>-um01h.
ELSE.
<fs_rep>-jan_cred = <fs_rep1>-um01h - <fs_rep1>-um01s.
ENDIF.
IF <fs_rep1>-um02s > <fs_rep1>-um02h.
<fs_rep>-feb_deb = <fs_rep1>-um02s - <fs_rep1>-um02h.
ELSE.
<fs_rep>-feb_cred = <fs_rep1>-um02h - <fs_rep1>-um02s.
ENDIF.
ENDLOOP.
repid = sy-repid.
*Build field catalog
wa_fieldcat-fieldname = 'JAN_DEB'. " Fieldname in the data table
wa_fieldcat-seltext_l = 'deb'. " ColuAN_DEBmn description in the output
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'JAN_CRED'.
wa_fieldcat-seltext_l = 'cred'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'FEB_DEB'. " Fieldname in the data table
wa_fieldcat-seltext_l = 'deb'. " Column description in the output
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'FEB_CRED'.
wa_fieldcat-seltext_l = 'cred'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_user_command = 'HANDLE_USER_COMMAND'
i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
it_fieldcat = it_fieldcat
TABLES
t_outtab = lt_report
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM html_top_of_page USING lw_document TYPE REF TO cl_dd_document .
DATA : doctable TYPE REF TO cl_dd_table_element,
col1_t1 TYPE REF TO cl_dd_area,
col2_t1 TYPE REF TO cl_dd_area.
*add quick table with five columns
CALL METHOD lw_document->add_table
EXPORTING
no_of_columns = 12
border = '1'
with_heading = 'X'
width = '150%'
IMPORTING
table = doctable.
*Filling columns in row
CALL METHOD doctable->add_column
EXPORTING
width = '8%'
IMPORTING
column = col1_t1.
*Filling columns in row
CALL METHOD doctable->add_column
EXPORTING
width = '8%'
IMPORTING
column = col2_t1.
CALL METHOD doctable->new_row.
CALL METHOD col1_t1->add_text
EXPORTING
text = 'JAN'.
CALL METHOD col2_t1->add_text
EXPORTING
text = 'FEB'.
ENDFORM. "html_top_of_page
As you can see I am trying to use html_top_of_page but the main headings are at the top and not inline with the subheadings. I know you can also use alv_list_display but I need grid display in-order to use filtering and sorting on the subheadings. The main headings does not need to use filtering or sorting or any other but they need to be on top of the subheadings and be inline with them where each heading should occupy two sub headings. It is possible to use one row scroll for the whole report? Also it is better if the main headings are self centered. How to achieve this?
Related
I want to extract all bkpf's fields into a tab delimited file in the background.
How can we do it?
Thanks in advance
Elias
PS: The code of the program that the Perform exec_in_bckgr doesn't understand the change of the Checkbox in SUBMIT WITH p_bckgr = space.
REPORT zfor_get_bkrf_bseg4.
TABLES: bkpf.
DATA: it_bkpf TYPE STANDARD TABLE OF bkpf,
ls_bkpf TYPE bkpf,
i_filename LIKE rlgrap-filename.
FIELD-SYMBOLS: <fs_field>.
SELECTION-SCREEN BEGIN OF BLOCK selection WITH FRAME TITLE text-s01.
SELECT-OPTIONS: so_bukrs FOR bkpf-bukrs,
so_budat FOR bkpf-budat OBLIGATORY.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN ULINE.
PARAMETERS: p_bkgrd AS CHECKBOX USER-COMMAND check DEFAULT 'X'.
" File Path on Application Server or on Local PC according to p_bkgrd
PARAMETERS: p_paths TYPE btcxpgpar DEFAULT '/tmp' MODIF ID sg1.
SELECTION-SCREEN END OF BLOCK selection.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_paths.
DATA: c_fnh_mask TYPE dxfields-filemask VALUE '*',
search_dir TYPE dxfields-longpath .
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = search_dir
filemask = c_fnh_mask
IMPORTING
serverfile = p_paths
EXCEPTIONS
canceled_by_user = 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_bkgrd = 'X'.
PERFORM exec_in_bckgr.
ELSE.
PERFORM get_data.
PERFORM download_tables_paths.
ENDIF.
END-OF-SELECTION.
WRITE: i_filename , ' is created' .
FORM get_data .
SELECT * INTO TABLE it_bkpf
FROM bkpf
WHERE bukrs IN so_bukrs AND
budat IN so_budat.
ENDFORM. " GET_DATA
FORM download_tables_paths .
DATA:lv_line(4096) TYPE c,
lv_field_type(10) TYPE c,
lv_field_text(10) TYPE c.
" Build FineName
CONCATENATE p_paths '/' 'BKPF' sy-datum sy-uzeit '.txt'
INTO i_filename.
REPLACE ALL OCCURRENCES OF '//' IN i_filename WITH '/'.
* Process further only if found some data
IF NOT it_bkpf[] IS INITIAL.
" Open file for Output
OPEN DATASET i_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
LOOP AT it_bkpf INTO ls_bkpf.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE ls_bkpf TO <fs_field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF lv_line IS INITIAL.
lv_line = <fs_field>.
ELSE.
DESCRIBE FIELD <fs_field> TYPE lv_field_type.
IF lv_field_type = 'P' OR lv_field_type = 'I'.
lv_field_text = <fs_field>.
CONDENSE lv_field_text NO-GAPS.
CONCATENATE lv_line '|' lv_field_text INTO lv_line.
ELSE.
CONCATENATE lv_line '|' <fs_field> INTO lv_line.
ENDIF.
ENDIF.
ENDDO.
TRANSFER lv_line TO i_filename.
CLEAR: lv_line.
ENDLOOP.
ENDIF.
CLOSE DATASET i_filename.
ENDIF.
ENDFORM.
FORM exec_in_bckgr .
DATA: jobname1 TYPE tbtcjob-jobname,
jobcount1 TYPE tbtcjob-jobcount.
jobname1 = 'ZFOR_GET_BKRF_BSEG2'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname1
IMPORTING
jobcount = jobcount1
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE s368(00) WITH 'Error Creating Job'
sy-subrc.
EXIT.
ENDIF.
SUBMIT zfor_get_bkrf_bseg2
WITH so_bukrs IN so_bukrs
WITH so_budat IN so_budat
WITH p_bckgr = space
WITH p_paths = p_paths
VIA JOB jobname1 NUMBER jobcount1
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount1
jobname = jobname1
* sdlstrtdt = sdate
* sdlstrttm = stime
* strtimmed = 'X' " Start immediately
EXCEPTIONS
invalid_startdate = 1
jobname_missing = 2
job_close_failed = 3
job_nosteps = 4
job_notex = 5
lock_failed = 6
OTHERS = 7.
IF sy-subrc > 0.
MESSAGE s368(00) WITH 'Closing Job Failed'
sy-subrc.
EXIT.
ENDIF.
ENDFORM.
The program is too simple and I do not understand why the site is asking me to add more comments.
OK, if I enable the strtimmed = 'X' in CALL FUNCTION 'JOB_CLOSE', then the program is creating jobs continuously and I have to kill it through SM50.
If I disable the STRTIMED then it create a job as SCHEDULE. I run it as Immediate and it creates and run a job without creating a file while in foreground the program is working perfect.
So my question is: Is this code OK for SAP ECC6?
Thanks in advance
Elias
The following code could be a solution.
Select your lines from BSEG in 10.000 packages, bring it in csv-format and transfer it into the open file.
DO.
SELECT * FROM bseg UP TO 10000 ROWS
INTO TABLE #DATA(lt_bseg)
WHERE bukrs = '0001'.
IF sy-subrc <> 0.
EXIT.
ENDIF.
OPEN DATASET filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT lt_bseg INTO DATA(ls_bseg).
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE ls_bseg TO FIELD-SYMBOL(<fs_field>).
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF line IS INITIAL.
line = <fs_field>.
ELSE.
line = line && ';' && <fs_field>.
ENDIF.
TRANSFER line TO filename.
CLEAR: line.
ENDDO.
ENDLOOP.
ENDDO.
CLOSE DATASET filename.
Finally someone told me what was wrong in my code. I missed a D in WITH p_bckgr = space.
I thought that if it is wrong the SAP will display an error, but this was a wrong thought.
So the correct is WITH p_bkgrd = space.
Thanks all
I have a program which has a checkbox and if the user enable it runs the program in background with the below code:
REPORT zfile_creation_app2.
*&---------------------------------------------------------------------*
*& Create file on Application Server
*& if the file exist, it will be deleted and created with new content
*&---------------------------------------------------------------------*
TABLES : sflight.
TYPES: BEGIN OF ty_sflight,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
fldate TYPE sflight-fldate,
END OF ty_sflight.
DATA: lv_file(255).
DATA: lt_sflight TYPE TABLE OF ty_sflight.
FIELD-SYMBOLS: <fs_sflight> LIKE LINE OF lt_sflight.
"-----------------------------------------"
" Selection Screen
"-----------------------------------------"
SELECT-OPTIONS: s_carid FOR sflight-carrid,
s_fldte FOR sflight-fldate.
" File Path on Application Server
PARAMETERS: p_path TYPE btcxpgpar DEFAULT '/tmp',
p_bckgrd(1) TYPE c DEFAULT 'X'.
"-----------------------------------------"
" Help Search for SAP Folder
"-----------------------------------------"
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
DATA: c_fnh_mask TYPE dxfields-filemask VALUE '*',
search_dir TYPE dxfields-longpath.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = search_dir
filemask = c_fnh_mask
IMPORTING
serverfile = p_path
EXCEPTIONS
canceled_by_user = 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.
"-----------------------------------------"
" Processing
"-----------------------------------------"
START-OF-SELECTION.
IF p_bckgrd = 'X'.
PERFORM start_in_background.
ELSE.
PERFORM get_data.
PERFORM extract_to_file.
ENDIF.
END-OF-SELECTION.
WRITE: lv_file , ' is created' .
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .
SELECT carrid connid fldate FROM sflight INTO TABLE lt_sflight
WHERE carrid IN s_carid[] AND
fldate IN s_fldte.
IF sy-subrc NE 0 .
RETURN.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form EXTRACT_TO_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM extract_to_file .
" Build FineName
CONCATENATE p_path '/' 'Flight' sy-datum sy-uzeit '.txt' INTO lv_file.
REPLACE ALL OCCURRENCES OF '//' IN lv_file WITH '/'.
" Check if File exists
OPEN DATASET lv_file FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0.
" If File Exists -> Delete it
CLOSE DATASET lv_file.
DELETE DATASET lv_file.
CLOSE DATASET lv_file.
ENDIF.
" Open file for Output
OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
" Transfer Data to file
LOOP AT lt_sflight ASSIGNING <fs_sflight>.
TRANSFER <fs_sflight> TO lv_file .
ENDLOOP.
" Close File
CLOSE DATASET lv_file.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form START_IN_BACKGROUND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM start_in_background .
DATA: d_jobcount LIKE tbtcjob-jobcount,
d_jobname LIKE tbtcjob-jobname.
d_jobname = 'ZFILE_CREATION_APP2'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = d_jobname
IMPORTING
jobcount = d_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE s368(00) WITH 'Error Creating Job'
sy-subrc.
EXIT.
ENDIF.
SUBMIT zfile_creation_app2
WITH s_carid = s_carid
WITH s_fldte = s_fldte
WITH p_bckgrd = space
WITH p_path = p_path
VIA JOB d_jobname
NUMBER d_jobcount
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = d_jobcount
jobname = d_jobname
strtimmed = 'X' " Immediate
EXCEPTIONS
invalid_startdate = 1
jobname_missing = 2
job_close_failed = 3
job_nosteps = 4
job_notex = 5
lock_failed = 6
OTHERS = 7.
IF sy-subrc > 0.
MESSAGE s368(00) WITH 'Closing Job Failed'
sy-subrc.
EXIT.
ENDIF.
ENDFORM.
Unfortunately the background job always canceling with the following error:
Enter date in the format __.__.____
This is the default setup for the user.
Can anyone know what cause the problem and how to fix it?
Thanks in advance
Elias
The problem is with so_budat. If your so_budat is a select option try using "in" instead of "=". See below.
so_budat IN so_budat.
I am new to Excel VBA scripting below are the issue I am facing :
1) Picking Material number from the excel cell and passing to the sales order created BAPI.
Data declaration
Dim Material As String
Material = ActiveSheet.Range("E14")
oItemsIn.Value(1, "MATERIAL") = Material
In This case the error message is there "Material 2094266 does not exist in sales area"
but if I pass material "000000000002094266" then it work fine
How I can change the format with leading Zero in the material number after picking value from the cell?
2) How I can pass material config (variant config) for the line item I am passing below values
Set CFGS_REF = oBapiCtrl.DimAs(boOrder, "CreateFromData", "OrderCfgsRef")
Set CFGS_VK = oBapiCtrl.DimAs(boOrder, "CreateFromData", "OrderCfgsInst")
Set CFGS_VALUE = oBapiCtrl.DimAs(boOrder, "CreateFromData", "OrderCfgsValue")
'OrderCfgsRefinst
CFGS_REF.Value("POSEX") = "000010"
CFGS_REF.Value("CONFIG_ID") = "000010"
CFGS_REF.Value("ROOT_ID") = "00000010"
' forOrderCfgsVk
CFGS_VK.Value("CONFIG_ID") = "000010"
CFGS_VK.Value("INST_ID") = "00000010"
CFGS_VK.Value("CLASS_TYPE") = "300"
'OrderCfgsValue
CFGS_VALUE.Value("CONFIG_ID") = "000010"
CFGS_VALUE.Value("INST_ID") = "00000010" ' Item
CFGS_VALUE.Value("CHARC") = "PRG_ORD_SOURCE"
CFGS_VALUE.Value("Value") = "Excel"
But it throws an error of data mismatch at CFGS_REF.Value("POSEX") = "000010"
To add the leading zeroes back to your material number:
oItemsIn.Value(1, "MATERIAL") = Format(Material, "000000000000000000")
I create a Pivot Table with a VBScript in QLikView:
sub cleanUp()
set sheet = ActiveDocument.Sheets("Summary")
set summaryTable = sheet.CreatePivotTable
summaryTable.addDimension "Product Group Desc"
summaryTable.addDimension "Product Type Desc"
summaryTable.addDimension "Product Sub Group Desc"
summaryTable.addDimension "Country"
summaryTable.addDimension "ZoneMgrName"
summaryTable.addExpression "Sum({<[Fiscal Year]={$(vCurrentYear)}>}
[Sales Amount])"
set props = summaryTable.getProperties
set expr = props.Expressions.Item(0).Item(0).Data.ExpressionVisual
expr.Label.v = "Expenses $(vCurrentYear)"
expr.NumAdjust = 1 'center
expr.LabelAdjust = 1 'center
summaryTable.SetProperties props
end sub
In addition I would like to create new fields used as dimensions. These fields are not in my QLikView document so far. The value for these fields is linked to the value of other fields. Say I have a field Country in my Pivot Table. I would like to add a new Field "Area" which contains the name of the area which the country belongs to. So that the values for the field would be the return value of a function which returns the area for a given country.
It depends on how your "lookup" data is accessed (whether it resides in your QlikView document, or is external), but you are free to add calculated dimensions to your pivot via the addDimension method. For example:
summaryTable.addDimension "=if(Country='France', 'EU', 'non-EU')"
You can use any normal expression that can return meaningful values for your dimension.
If you wish to name the dimension, you can use addDimension's return value as follows:
dimensionNum = summaryTable.addDimension("=if(Country='France', 'EU', 'non-EU')")
set tableProperties = summaryTable.getProperties
set calcDim = tableProperties.Dimensions.Item(dimensionNum-1)
calcDim.Title.v = "Area"
summaryTable.SetProperties tableProperties
Is it possible to set a selected Data Grid View column name to a variable.
Example of my code.
Dim cmevoids As DataTable = ds.Tables(0)
Dim test As String
test = "event_code"
Dim Query = From payments In cmevoids.AsEnumerable() _
Where payments.Field(Of String)("event_code") = "MB120117"
Where payments.Field(Of String)("event_transaction_status") = "PAID"
Order By payments.Field(Of String)("event_code") _
Select New With {.event_code = payments.Field(Of String)(test), _
.event_transaction_status = payments.Field(Of String)("event_transaction_status"), _
.event_transaction_detail_amount = payments.Field(Of String)("event_transaction_detail_amount")}
dgvQuery.DataSource = Query.ToList()
I want to take w/e column the user selects from a combo box from the first data grid view and display it in a 2nd data grid view for query's.
I can get it to search and display the table selected by the variable given as shown by the test variable. But i can't get it to change the column name in the query data grid view to the name of the variable. I can only get it to name it w/e i have hard coded in, in this case event_code, event_transaction_status and event_transaction_detail_amount.
Any way to do this without hard code but variable?
What about populating the gridview like you have been but then change it after it is bound?
Dim Result as string = "w/e column the user selects from a combo box"
Dim i as integer = 0 'your colum index
GridView1.Columns(i).HeaderText = Result