• Home
  • About me
  • FALV
  • ALV Grid in the nutshell
    • Basic Information
    • Field catalog
  • Articles
    • Tricks
    • FALV (Fast ALV Grid)
    • ALV Grid in the nutshell
    • Tips
    • How to...
    • For beginners
    • Thoughts
  • By Topic
    • ALV
    • ALV OO
    • SALV
    • GOS
    • Selection screen
    • Purchase Requisitions
    • Purchase Orders
    • Attachments
    • Others
    • Characteristics
    • Sample Programs
    • ZIP
    • OLE
    • Mails
    • Routings
    • EWB
    • Excel
  • Keywords
  • RSS
  • Download
  • Home

Create a nice looking chart with CL_GUI_CHART_ENGINE - Part 1 - Chart Designer

Details
Łukasz Pęgiel
How to...
03 May 2013
Hits: 34547
Tags: CL_GUI_CHART_ENGINE , chart designer
At the beginning of my work with SAP I was disappointed with the charts that was available in standard transactions. In fact I am still :) But when I have to create own program with nice looking chart then it's no longer a problem as we can use CL_GUI_CHART_ENGINE together with chart designer provided by SAP. Chart designer is a tool which allows you to create a customizing for your chart and save it in XML file which can be used in ABAP after.

So first of all we need to download chart designer from SDN so you can google "sap chart designer" to get it. After you'll have it just run one of the versions available there (640 or 700) depending on your GUI version. All files which you'll find in the package are shown below, XML Format.pdf file will tell you how to prepare chart data depending on chart type.
 

Add a comment
Read more ...

Load variant to single subscreen (selection screen)

Details
Łukasz Pęgiel
How to...
02 May 2013
Hits: 20667
Tags: RS_VARIANT_CATALOG , RS_VARIANT_CONTENTS , RS_ISOLATE_1_SELSCREEN
In article Save variant for single selection screen subscreen I've shown you how to save a variant for single selection-screen subscreen with a little help of FM RS_ISOLATE_1_SELSCREEN & RS_CREATE_VARIANT. If you use method shown there it may happen that when you're loading a variant to a screen it overrides also values from other fields. To avoid that I've prepared a method to fill only fields from one subscreen. I will use here FM RS_VARIANT_CATALOG to allow user to select variant for subscreen, FM RS_VARIANT_CONTENTS to read it's content, FM RS_ISOLATE_1_SELSCREEN to get the fields of subscreen and field-symbols to put them on place. So let's start.
 
As input parameter I will use only subscreen number:

i_dynnr type sy-dynnr  -> subscreen number

Add a comment
Read more ...

Subtotal lines of ALV GRID OO as content separator

Details
Łukasz Pęgiel
Tricks
28 April 2013
Hits: 50405
Tags: NO_TOTEXP , NO_TOTLINE , NO_ROWMARK , SUBTOTAL_TEXT , CL_GUI_ALV_GRID
ALV Grid gives us some possibilities for easier reading of the grid content like "zebra" or colored rows. But when this is not enough and you want to make sure that users will focus on part of the rows only, then you have additionally two options:
1st) Add empty line after each part you want to separate and color it differently; 
2nd) Use subototals of ALV Grid to do it instead of you (but without any values).

Adding empty lines will force you to delete all of them each time you'll do changes inside table displayed in grid and you'll have to do the calculation of position again, that's why today I will show you the second option. 
I will use event subtotal_text for cl_gui_alv_grid, three additional colums in internal table (for sorting and separating key) and  lvc_s_layo settings NO_TOTEXP, NO_TOTLINE, NO_ROWMARK.
Add a comment
Read more ...

Secure call of "starting new task" using RM_FREE_SESSION_CHECK

Details
Łukasz Pęgiel
Tips
25 April 2013
Hits: 39627
Tags: RM_FREE_SESSION_CHECK , TH_USER_INFO , STARTING NEW TASK
When you need to call a FM with option starting new task there is always a risk that user already has maximum number of sessions opened, so there is a risk that our call will be unsuccessful. There is a way to avoid such risk -> easily call FM  RM_FREE_SESSION_CHECK or TH_USER_INFO directly to check if we can afford to open new session. If yes then we can call our FM in new task, if not then we can raise an error message and stop processing of the function we're currently doing. This is very helpful when you need to call a FM in new task inside user-exit.
 
Here is example of the code:
Add a comment
Read more ...

F4 Help for external date

Details
Łukasz Pęgiel
How to...
24 April 2013
Hits: 13744
Tags: PERIOD_AND_DATE_CONVERT_OUTPUT , F4_DATE
In one of the previous articles I described how to Convert date to and from external date type, so we can display in grid or in screen field properly formated date. Today I will show how to create a F4 help for such external date. I will use today FM 'F4_DATE' to show the date popup and already know FM 'PERIOD_AND_DATE_CONVERT_OUTPUT' to convert internal date to external type.

Importing:

IM_DISPLAY TYPE CHAR1  - Display only? (no selection)
IM_ELPEI TYPE TPRG-PRGBZ (OPTIONAL) -  External date type

Exporting:

EX_EEIND TYPE RVDAT-EXTDATUM   - External date
EX_ELPEI TYPE TPRG-PRGBZ       - External date type

Add a comment
Read more ...

Save variant for single selection screen subscreen

Details
Łukasz Pęgiel
How to...
23 April 2013
Hits: 24281
Tags: RS_REFRESH_FROM_SELECTOPTIONS , RS_ISOLATE_1_SELSCREEN , RS_CREATE_VARIANT , RS_CHANGE_CREATED_VARIANT
When building a program with multiple selection screens sometimes it may be needed to save the variant with entries only for one of the subscreens and not for the others. If you want to do that you have to firstly use FM 'RS_REFRESH_FROM_SELECTOPTIONS' to get all fields and values for all select-options, then you need to use FM 'RS_ISOLATE_1_SELSCREEN' to get the fieldnames for selected subscreen. When you have this data you can easily filter fileds and it's values to this which you have on your subscreen. After that run FM 'RS_CREATE_VARIANT' to create a new variant, if variant exists and you want to overwrite it then you have to use 'RS_CHANGE_CREATED_VARIANT'.  Few lines and you can use this in many developments.
 
Importing parameters:

I_DYNNR TYPE SY-DYNNR - Current Screen Number
I_VARNAME TYPE RSVAR-VARIANT - Variant Name
I_VARTEXT TYPE VARIT-VTEXT - Program variant short text

Add a comment
Read more ...

Refresh ALV GRID and keep position and current cell

Details
Łukasz Pęgiel
Tricks
22 April 2013
Hits: 127502
Tags: CL_GUI_ALV_GRID , GET_SCROLL_INFO_VIA_ID , GET_CURRENT_CELL , GET_SELECTED_ROWS , GET_SELECTED_CELLS_ID , REFRESH_TABLE_DISPLAY , SET_SELECTED_CELLS_ID , SET_SELECTED_ROWS , SET_SCROLL_INFO_VIA_ID , SET_CURRENT_CELL_VIA_ID

When you use CL_GUI_ALV_GRID in edit mode or you change your internal table used to display data on ALV grid it may happen that after refreshing the grid using refresh_table_display your cursor or scroll goes to the begining of the grid. Users feels little lost in such situation but there is an easy solution for that.

data: is_stable type lvc_s_stbl.
is_stable-row = 'X'.
is_stable-col = 'X'.
"or 
is_stable = 'XX'.

grid->refresh_table_display(
  exporting
    is_stable      =   is_stable   " With Stable Rows/Columns
*    i_soft_refresh =   i_soft_refresh  " Without Sort, Filter, etc.
  exceptions
    finished       = 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.

EDIT: Method of mine which can be found bellow doesn't have to be used to achieve your goal. To be honest I can't remember why I created separate version of it as only the cursor act a bit different than oryginal one. I must have had mind eclipse at the time :-) . Excuse me for that.

So to keep scroll position and current cell we will need to use  following methods of CL_GUI_ALV_GRID:

  • get_scroll_info_via_id - gets current scroll information

  • get_current_cell         - gets current cell, we will use that data to set the cursor at the end

  • get_selected_rows      - gets selected rows

  • get_selected_cells_id  - if we didn't select any rows, we check for the selected cell information

  • refresh_table_display  - then simple refresh of grid

  • set_selected_cells_id   - after refresh it's time to set back all information, so set selected cell

  • set_selected_rows       - or set seleted rows (depanding what we received at the begining)

  • set_scroll_info_via_id  - set scroll position back

  • set_current_cell_via_id - set cursor back.

There is no special coding here, just standard ALV grid methods used in proper order.

Method definition, Importing parameters:

I_SOFT TYPE CHAR01  DEFAULT 'X' 
I_SET_CURRENT TYPE CHAR01  DEFAULT SPACE 
I_SET_SELECTED TYPE CHAR01  DEFAULT SPACE

Changing parameters:

GRID TYPE REF TO CL_GUI_ALV_GRID 

Add a comment
Read more ...

Delete Routing - piece of cake

Details
Łukasz Pęgiel
How to...
18 April 2013
Hits: 22691
Tags: CP_CC_S_LOAD_COMPLEX_BY_TSK , CP_CC_S_DELETE_BY_TSK , CP_CC_S_SAVE , CP_CL_TSK_UNLOCK , BAPI_ROUTING_DELETE? , CP_CC_S_DELETE_BY_MTK

Not once, not twice I've search for a solution to do changes in routings (task lists) in some wise way. I hate BDC but in this case I thought that there is no other solution. Fortunately I was wrong ! While reading one of the post asking about same thing one of the users has mention something really nice - SAPNote 488765 "Do-it-yourself EWB programming". This note shows how to use FM used in CEWB, so we can create/change/delete bom and routings. The example available in the note shows how to change an routing operation description. The rest you have to figure out alone but once you start to use the functions or you'll check "where used" then it became quite easy (but not less time consuming).  When you find the function you're seeking then it's piece of cake.

It was like that also with delete routing function which I share with you today. There is no BAPI_ROUTING_DELETE (yet), so firsty we had to load the task to EWB memory with 'CP_CC_S_LOAD_COMPLEX_BY_TSK' ,then it's time to set deletion indicator in MAPL ('CP_CC_S_DELETE_BY_MTK') and in PLKO ('CP_CC_S_DELETE_BY_TSK'). At the end we have to save the changes  with 'CP_CC_S_SAVE' and dequeue task with 'CP_CL_TSK_UNLOCK'. If you need you may also delete the operations but in my opinion this is not needed here.

Add a comment
Read more ...

Creating editor for dynamic code (SE38 like)

Details
Łukasz Pęgiel
How to...
17 April 2013
Hits: 16983
Tags: SYNTAX-CHECK , RS_TOOL_ACCESS , EDITOR_TABLE_WITH_STATUS , SAPGUI_SET_FUNCTIONCODE , PRETTY_PRINTER

I had a thought one day to use a code saved in database table for easy change of some calculation rules and I've prepared code to run SE38 like editor for such code. Maybe some of you also had such need, so today I will explain briefly how to do this. I will use FM 'EDITOR_TABLE_WITH_STATUS' to display an editor which you know from SE38/SE80 , 'SAPGUI_SET_FUNCTIONCODE' for setting OK_CODE for editor, 'PRETTY_PRINTER' to make our code looks readable. I will also use one trick that allows you to assign data which is available in calling program but not in our function. But before we need to prepare our own GUI status with some basic buttons like 'Patern' or 'Pretty Printer'.

Add a comment
Read more ...

Save message with attachment in Outlook's Drafts

Details
Łukasz Pęgiel
Tricks
16 April 2013
Hits: 36341
Tags: OLE2_OBJECT , MS OUTLOOK , OUTLOOK.APPLICATION

In previous post I've shown how to zip file directly on PC without using CL_ABAP_ZIP, this time I will show you how easy is to use OLE2_OBJECT to create an MS Outlook message with attachment and save it in Outlook's Drafts folder. OLE2_OBJECT in fact can be used with any application that allows it, but today I will only show a hint how to work with MS Outlook.

I know that most of us use CL_BCS to create and send the message directly from SAP, but in a situation when you're working on local files then It may be better to do it with Outlook. This is of course just a short sample of the possibilities, all functions for OLE & MS you can find in MSDN documents.


Here is the code with f_path parameter which is used to pass path of local file to attach to message:

Add a comment
Read more ...

Zipping in IZArc with ABAP directly on PC

Details
Łukasz Pęgiel
Tricks
15 April 2013
Hits: 14008
Tags: CL_GUI_FRONTEND_SERVICES=>EXECUTE , CL_GUI_FRONTEND_SERVICES=>ENVIRONMENT_GET_VARIABLE , CL_GUI_FRONTEND_SERVICES=>FILE_EXIST , CL_ABAP_ZIP

From time to time you have to work on files that are stored in user PC, like when you're working with SOI (SAP Office Integration) for example. All operations that are done are save directly to a file which is stored on PC so if you would like to zip it with cl_abap_zip class then you would need to copy file to ABAP memory, then zip it using cl_abap_zip and then save back file to PC. Sometimes this is not the best solution, especially when working on slow connections via VPN or similar. So with help there goes cl_gui_frontend_services=>execute. This method allows you to run every file on PC directly - also a program with proper parameters. In my example I will use IZArc (it's free and fast).

So what I'm doing here is:
- passing full path to the file which will be zipped
- call cl_gui_frontend_services=>environment_get_variable to check program files directories
- concatenate file path with parameter of IZArc "-ad"
- concatenate program files directories with 'IZArc\IZArc.exe'
- check if IZArc exists with  cl_gui_frontend_services=>file_exist
- if yes then I'm executing it with cl_gui_frontend_services=>execute.

Here is the full code for such function:

Add a comment
Read more ...

Download CV01N/2N/3N documents to PC

Details
Łukasz Pęgiel
How to...
14 April 2013
Hits: 37771
Tags: CVAPI_DOC_GETDETAIL , CVAPI_DOC_CHECKOUTVIEW , SCMS_DOC_READ , SCMS_BINARY_TO_XSTRING , SCMS_XSTRING_TO_BINARY

You might have a task to use or download one or all files attached to document saved via CV01N transaction. This is not a big deal really, you just need to use some FMs available in standard of SAP like  'CVAPI_DOC_GETDETAIL', 'CVAPI_DOC_CHECKOUTVIEW' or  SCMS_DOC_READ'.  These FMs allows you the check the details of document, check it and then read its content. Of course sometimes you'll have to zip the files before the downloading and here in my code I used method "zip" for which code you can find here.  While reading the code you may also find another Z-method called "get_filename_from_path", its code is posted here. The method I'm posting bellow allows you to choose if during download of files from document you want to zip them all together into one zip file or if you want to zip them separatelly. In table ET_FILES you'll find all files that were attached to document, field "UPDATEFLAG" will be set to 'D' if file was succesfully downloaded to PC. If you don't want to download the file but you want to get it for futher use you'll have to request ET_XSTRING table. In other case do not request this parameter as it is a sign for method that you don't want to donwload the files.

Types:

TT_RA_FILENAME type range of CVAPI_DOC_FILE-FILENAME.
TT_XSTRING type table of xstring.

Importing:

I_DOKAR TYPE DRAW-DOKAR ->Document Type
I_DOKNR TYPE DRAW-DOKNR ->Document number
I_DOKTL TYPE DRAW-DOKTL   ->Document Part
I_DOKVR TYPE DRAW-DOKVR  ->Document Version
I_DOWNLOAD_DIRECTORY TYPE STRING -> path to download the fiels
I_ZIP_FILES TYPE C OPTIONAL -> mark it 'X' if you want to zip the files before downloading
I_ZIP_SEPARATELY TYPE C OPTIONAL -> mark it 'X' if you want to zip each file found in document separately
I_NAME_FILTER TYPE TT_RA_FILENAME OPTIONAL -> Range for filter filenames - select which documents you want to download
I_FILENAME TYPE CSEQUENCE OPTIONAL -> filename for zip - used if you zip all files into zip container

Exporting:

ET_FILES TYPE CVAPI_TBL_DOC_FILES -> Table with all files found in document 
ET_XSTRING TYPE TT_XSTRING -> TT_XSTRING -> Table of xstrings (each file in separated line)

Exceptions:

ZIP_ERROR -> Error while zipping
DOCUMENT_ERROR -> Error while reading document

Add a comment
Read more ...

ZIP a file using ABAP

Details
Łukasz Pęgiel
How to...
13 April 2013
Hits: 28771
Tags: CL_BCS_CONVERT , CL_ABAP_ZIP , SCMS_STRING_TO_XSTRING

Although our connections are now so fast we may still need sometimes to compress data before attaching to mail or downloading into PC. SAP has possibilities to ZIP the content in class CL_ABAP_ZIP and I've used this class to create a method to simplify the process of zipping.

First of all class CL_ABAP_ZIP is zipping xstrings so I'll provide you the possibility to pass not only xstring variables but also a string, soli_tab or solix_tab. These are commonly used type when coding files content.

Add a comment
Read more ...

Get filename and extension from full path

Details
Łukasz Pęgiel
How to...
13 April 2013
Hits: 36194
Tags: FILENAME , EXTENSION

I guess all of us often had to work with files in ABAP usign some of available FM like 'GUI_UPLOAD', 'GUI_DOWNLOAD' etc. When doing so sometimes there is a need to display in ALV the filename with or without extension . There are plenty of FM that helps to do so but the have one disadvantage -> they base on 3 digit extension and sometimes they have limited path size.

But where stadard SAP cannot help you, then you have to helpyourself with ABAP. There is a really simple way to split filename/extension without any restrictions known from standard FM. Here is a code for a method, but you can use it also to create form or FM. 

Add a comment
Read more ...

More Articles ...

  1. Link Attachments of Purchase Requisition to Purchase Order
  2. Convert date to and from external date type
  3. Free global data of a program at once
Page 10 of 11
  • Start
  • Prev
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • Next
  • End


Łukasz Pęgiel
ALV GRID ALV Grid in the nutshell Field catalog - quantity How to copy BOM using CEWB Function Modules Secure call of starting new task using RM FREE SESSION CHECK LVC FCAT RECEIVE RESULTS FROM FUNCTION GUI ALV GRID ABAP Extensions - Automatic Logon SAVE Field catalog - inttype - ABAP data type SAP SCRIPT ALV GRID IN THE NUTSHELL CMD API SAPGUI PROGRESS INDICATOR REUSE FIELDCATALOG MERGE REFRESH DATA MDC7 CTMS DDB SET VALUE ONLINE KEY DESCRIBE NAME ALINK CONNECTION Field catalog - datatype SE41 Field catalog - checkbox RSDBRUNT VRM VALUES EMPHASIZE READ USER SETTINGS EXPORT TO MEMORY ID ABAP IN ECLIPSE ZDEMO Field catalog - outputlen PROVIDE COM OPR ISOLATE SELSCREEN TABLE DISPLAY TOOL ACCESS ECLIPSE Load variant to single subscreen selection screen KKEK CONVERT FLOAT CURR BOM MBM OUTLOOK APPLICATION EXPONENT AiE ADT dark theme settings MEREQ GET FACTORY SLICENSE ABAP ZIP ESRUO CVAPI DOC GETDETAIL ABAP FAVORITES SAP NPL OBJECTS MAT CREATE COPY SELECT Configure FUNCTIONCODE Field catalog - rollname
  • Laserowe usuwanie blizn Tychy
  • Laserowe usuwanie zmarszczek Tychy
  • Salon Kosmetyczny Tychy
  • Trycholog Tychy
  • Wypadanie włosów Tychy
Tweets by abapblog

Eclipse Plugins for ABAP

ABAP Favorites

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

ABAP ADT Extensions

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

ABAP Quick Fixes

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

 

Latest Articles

  • ABAP in Eclipse - Install, Configure, Use, and Enhance Your ADT
  • ALV Grid in the nutshell: Field catalog - col_id - ALV control: Column ID
  • ALV Grid in the nutshell: Field catalog - dfieldname – Fieldname for column group
  • ALV Grid in the nutshell: Field catalog - Hotspot - ALV control: SingleClick-sensitive
  • ALV Grid in the nutshell: Field catalog - sp_group - Group key
  • ALV Grid in the nutshell: Field catalog - domname - Domain name
  • ALV Grid in the nutshell: Field catalog - reprep - ALV control: Value is selection criterion for rep./rep.intf.
  • ALV Grid in the nutshell: Field catalog - reptext – Heading
  • ALV Grid in the nutshell: Field catalog - lowercase - Lowercase letters allowed/not allowed
  • ALV Grid in the nutshell: Field catalog - intlen - Internal Length in Bytes
  • Downloading Exchange Rates from NBP (National Bank of Poland)
  • Downloading Exchange Rates from Central Bank of Turkey
  • ABAP Extensions - Automatic Logon
  • ALV Grid in the nutshell: Field catalog - inttype - ABAP data type (C,D,N,...)
  • ALV Grid in the nutshell: Field catalog - datatype

Most Read

  • Create XLSX/MHTML file from internal table in background
  • Refresh ALV GRID and keep position and current cell
  • Create XLSX file from internal table in background v2
  • FALV (Fast ALV Grid)
  • ATC Pseudo Comments list
  • Call standard F4 search help with customized parameters
  • Dynamic GUI STATUS & TITLE with ABAP code
  • Create fieldcatalog from internal table
  • Link Attachments of Purchase Requisition to Purchase Order
  • GOS - How to add business documents at creation of object
  • Endless loop in BADI ME_PROCESS_PO_CUST
  • Create a nice looking chart with CL_GUI_CHART_ENGINE - Part 3 - Chart Data and render
  • How to access private or protected data and methods of CL_GUI_ALV_GRID
  • Subtotal lines of ALV GRID OO as content separator
  • Popup with multi-select ALV
feed-image Feed Entries

Latest Comments

ABAP code and articles provided on http://abapblog.com, if it is not statet otherwise, were created by Łukasz Pęgiel. You can use the code in your SAP instance for commercial and non-commercial use without any warranty from side of the author. You cannot sell the code as a full program or a part of it.
Replicating of the articles and code is prohibited unless the agreement of the author is given to you. 

Bootstrap is a front-end framework of Twitter, Inc. Code licensed under MIT License. Font Awesome font licensed under SIL OFL 1.1.