5 1 1 1 1 1 Rating 100% (1 Vote)
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 ...

5 1 1 1 1 1 Rating 100% (1 Vote)
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

Read more ...

5 1 1 1 1 1 Rating 100% (2 Votes)

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

1 1 1 1 1 Rating 0% (0 Votes)

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

5 1 1 1 1 1 Rating 100% (1 Vote)

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

1 1 1 1 1 Rating 0% (0 Votes)

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

5 1 1 1 1 1 Rating 100% (1 Vote)

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

1 1 1 1 1 Rating 0% (0 Votes)

You've seen many times that in standard SAP transactions the dates can be presented in days, weeks and months although in database it's saved as normal DATS type. For sure in same table you can find the field called "External date type" which is used to convert standard date to external one. If you're designing a program in which you want to use same functionallity then FM 'PERIOD_AND_DATE_CONVERT_OUTPUT' and 'PERIOD_AND_DATE_CONVERT_INPUT' comes with a help.

Add a comment
Read more ...
Page 5 of 5