SAP - Reading data from Application Server by using File system commands

Dear All,
Welcome back to my blog.

We may get a requirement to read data from Application server. But, if you don't find proper function Module then, you can simply use steps and get the details from App. Server.

Execute Program RSFTP002:

  
Will get above selection screen. Here we need to pass below parameters, those are:



User -  FTP User name
Password - Password to open FTP server
Host -  IP address of FTP server
Command1 -  Enter FTP Command 1
Command2 - Enter FTP command 2
Command3  - Enter FTP Command 3

RFC Destination - By default it is SAPFTP - you have to check the name of RFC Destination in your system.
Compress  -  N

Command1, Command2, Command3:
These three options are provided for us to write Unix commands to run on File server system.
Example Commands are:

Command1  -  CD  Dir Name
 Now, system will open Directory in FTP Server.
Command2 - get File name
Properties of File name will be shown with this command.

For other commands refer to Unix File management commands and use it over here.

If you wanted to execute only one command, then you can ignore other two options. It is not mandatory to use all Command Options.



If you feel it is useful kindly share your feedback.


Regards
Vamsi Krishna

DTP filter routine example

We will get a requirement to write DTP filter routines.
At that time we need to follow simple steps then, our routine will be ready... :)

Create Routine for selection field in routine.
Now we need to follow below steps:

form compute_

After this statement we need to implement our own customised code and return l_t_range internal table.

        l_t_range-sign = 'I'.
         l_t_range-option = 'EQ'.
        l_t_range-iobjnm = '0CALDAY'.
         l_t_range-fieldname = 'CALDAY'.
         l_t_range-low = '20110101.
         append l_t_range.

That's it.. it will work for CALDAY.

Make your own code and Pass following Parameters.. then, it will work...


- Vamsi.

How to find Source and Target details in DTP Filter Routine

When we are writing code in filter routines we may get a requirement to find out InfoSource and Target Info Cube details.

BI7 is designed based on Object Oriented technology. Just copy and paste following code into your filter routine.

* Target InfoProvider
 DATA :  I_TGT type RSBKTGTNM,
   s_src type RSBKSRCNM.

* get target details
    CALL METHOD i_r_request->GET_TGT
       RECEIVING
          R_TGT = I_TGT.


* get Source details
   CALL METHOD i_r_request->GET_SRC
       RECEIVING
          R_SRC = S_SRC.


Please watch this blog for more updates on BI7.




How to write code in start routine - BI7?

Unlike BW3.5, will have different structures in BI7.
Basically BI7.O follows OOPs concepts. Here, you can find methods and classes.

We have all the information in single page. Top of the screen we can find declaration of all Variables.

Now need to search for method with Start_Routine. At there we can see "Insert your comment"

Here instead of DATA_PACKAGE we need to use SOURCE_PACKAGE.

Code looks like this:

loop at SOURCE_PACKAGE  assigning <source_package>.

* modify data in structure <source_package> that will automatically effects in the target structure.

endloop.

Clubbing all Data packages into together an processing as one data packet

Hi Friends,
We may get requirement that, you need to club all the data package data into one internal table in start routine and then after if you want to send it to further targets.. :) Is it Possible in BW?
Yes It is Possible. Stop all the data packets and process them in one sequence is possible.
In BW 3.5 We can club all data packets together into one data packet in start routine.
In Start routine we can club all the data packet data into one internal table, then after you can send this internal table for further processing.

Logic to stop data packets:

DATA: packet_nbr TYPE i VALUE 1.

DATA: y_requnr TYPE rsrequnr.

DATA: Is_rec TYPE string VALUE 'G_S_IS-RECNO',
is_requnr TYPE string VALUE 'G_S_MINFO-REQUNR',
it_rsmonfact TYPE STANDARD TABLE OF ls_rsmonfact
FIELD-SYMBOLS: TYPE ANY,
TYPE ANY.
ASSIGN (is_requnr) TO .

SELECT dp_nr FROM rsmonfact
INTO TABLE it_rsmonfact
WHERE rnr = .

DESCRIBE TABLE it_rsmonfact LINES v_packet_max.

IF v_packet_nbr < v_packet_max.
APPEND LINES OF DATA_PACKAGE[] TO lt_data_package_collect[].
CLEAR: DATA_PACKAGE.
REFRESH DATA_PACKAGE.
v_packet_nbr = v_packet_nbr + 1.

CLEAR: MONITOR[], MONITOR.
MONITOR-msgid = '00'.
MONITOR-msgty = 'I'.
MONITOR-msgno = '398'.
MONITOR-msgv1 = 'All data_packages have been gathered in one. '.
MONITOR-msgv2 = 'The last DATA_PACKAGE contains all records.'.
APPEND MONITOR.

ELSE.
last data_package => perform Business Rules.
IF v_packet_max > 1.
APPEND LINES OF DATA_PACKAGE[] TO lt_data_package_collect[].
CLEAR: DATA_PACKAGE[], DATA_PACKAGE.
Write your logic @ here....

ENDIF.
ENDIF.

Dwonloading internal table into Pivot table using function moudle XXL_SIMPLE_API



Hi Friends,

Now we are discussing on how to download the data from internal table Excel in tabular format or Pivot table Format by using Function Moule "XXL_SIMPLE_API".



Here i am sharing you the example program:

EPORT ZDOWNLOAD_PIVOT.
data : begin of it_data occurs 0,
vbeln type vbeln_va,
posnr type posnr_va,
matnr type matnr,
NETPR type NETPR,
end of it_data.

DATA : " XXL_SIMPLE_API parameters and tables
y_filename LIKE gxxlt_f-file, " File name on the workstation
y_header LIKE gxxlt_p-text, " XXL interface: texts for printing a list
y_wa_col_text TYPE gxxlt_v,
y_it_col_text TYPE TABLE OF gxxlt_v, " Headings for DATA columns
y_wa_online_text TYPE gxxlt_o,
y_it_online_text TYPE TABLE OF gxxlt_o, " Table with online texts
y_wa_print_text TYPE gxxlt_p,
y_it_print_text TYPE TABLE OF gxxlt_p. " Table with print texts

*Selction Screen Options

SELECT-OPTIONS s_vbeln FOR it_data-vbeln.

*Retriving data

SELECT * from vbap INTO CORRESPONDING FIELDS OF TABLE it_data where vbeln IN s_vbeln.

IF sy-subrc NE 0.

MESSAGE 'No Data' TYPE 'I'.

ENDIF.


y_filename = 'download.xls'.
y_header = text-001. " Header Information "

* Column Headings

y_wa_col_text-col_no = '1'.
y_wa_col_text-col_name = 'Sales Order Number'.

APPEND y_wa_col_text TO y_it_col_text.

y_wa_col_text-col_no = '2'.
y_wa_col_text-col_name = 'Item Number'.
APPEND y_wa_col_text TO y_it_col_text.

y_wa_col_text-col_no = '3'.
y_wa_col_text-col_name = 'Material'.
APPEND y_wa_col_text TO y_it_col_text.

y_wa_col_text-col_no = '4'.
y_wa_col_text-col_name = 'Net Price'.
APPEND y_wa_col_text TO y_it_col_text.

* Calling a function module to down load the data

CALL FUNCTION 'XXL_SIMPLE_API'
EXPORTING
filename = y_filename
header = y_header " Heading
n_key_cols = 1 " Number of (hierarchical) key columns
TABLES
col_text = y_it_col_text
data = it_data
online_text = y_it_online_text
print_text = y_it_print_text
EXCEPTIONS
dim_mismatch_data = 1 " Non-present DATA column is referenced
file_open_error = 2 " File FILENAME cannot be opened
file_write_error = 3 " File FILENAME cannot be written to
inv_winsys = 4 " Wrong window system, DOS windows required
inv_xxl = 5 " Installation at the frontend incorrect
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*******************************************************************


After that you need to save and activate it.


“Error generating the test frame” In SE37

Normally when we are executing some function modules (through SE37) we will get some kind of error like “Error generating the test frame”.

Solution:
This error will come when we have complex parameters in the Function modules.
Test environment of function builder can’t represent these parameters in the import tab (in input) For example : generic data types, Strings, xstrings, Object references.

For more information on this check SAP OSS notes.
Regards,
Vamsi

BAPI - Overview

BAPI – Business Application Interface.
BAPI’s are defined in business object repository as methods on SAP business Objects.
These are enables the object oriented view on R/3 application modules and thus basis for the R/3 business frame work development. Because of their open and defined interfaces, these are also used by other applications like Visual Basic etc.
To check BAPI based application wise you need to use the T.code called BAPI.
Here you can find the information of all the BAPI’s by Application area.
Example:
Like if you are looking for a BAPI for Sales Order change in Sales and Distribution area, then, In left side pane Go to Sales and Distribution à Sales à ChangeFromData (method)
Will get the function module BAPI_SALESORDER_CHANGE, always BAPI function modules are Remote enabled and used in events.

You can see the Documentation for this on Documentation tab.

The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. For doing this we have to use another BAPI function module, BAPI_TRANSACTION_COMMIT BAPI.

How to activate External Debugger

When we wanted to debug a web page then we need an external debugger to be activated. Other wise we can't debug that session with session debugger (normally we will use seesion debugger). For using external debugger we need to follow below steps:

In T.code SE38, In Menu Go To --> Utilities à Settings --> ABAP Editor -->Debugging Use check mark on Active and provide user id. If the same user id is used in multiple systems and if want to stop only in one system then you can use option called IP matching.

Regards,

Vamsi

Fetching the data from Memory in SAP

Fetching the data from memory means, we may get a requirement that we need to submit any report with return option.In those cases we need to get the out put of that particular report. At that time, we can use the following piece of code in our program, that will retrieve the data from memory and stored in the internal table.


SUBMIT <>
USING SELECTION-SET <>
EXPORTING LIST TO MEMORY
AND RETURN.


Step 1:

We can use List_from_memory Function module to fetch the data from memory:



*Import the data into one internal table
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = y_i_abaplist
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
ENDIF.


Step2 :
Now we need to convert it into internal format. That data from above function module is in ascii format.

*Convert to ASCII format
IF NOT y_i_abaplist[] IS INITIAL.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = y_i_ascilist
listobject = y_i_abaplist
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc = 0.
ENDIF.
ENDIF.

ENDFORM. " y_f_liste


In the out put internal we will get the out put of internal table y_i_abaplist.


Have a good day.... :)

Thank U.
Vamsi.

Creating Search Helps by vams

Search Helps :
  • Search Helps are nothing but, F4 helps in SAP system.
  • Search helps are two types :

a) Elementary Search Helps

and b)

Elementary Search Helps :

GoTo T.Code SE11, Click the radio button Search Help and enter the name and create.

Provide description.

Enter the data Source name i.e., iether table or view.

In the fields section, enter all the required fields along with SPOS field.

Once every thing is over activate it and test at there only.

Now we will get the required search option on the particular field.

Thanks and Regards

Vamsi.

Wroking With Filed Symbols

Many People affraid in writing the code with field symbols.
It's very simple. Field symbols are directly point to memory. So, If we modified the data in the field symbols it will directly effect to the memory.
Syntax : FIELD-SYMBOLS : TYPE .
Use ASSIGNIG statement to use field symbols.
Eg:
Declaration:
TYPES : BEGIN OF ty_itab,
A type N,
B type i,
C type i,
D type i,
END OF ty_itab.

FIELD-SYMBOLS : < wa > type ty_itab.
data : itab type standrad table of ty_itab.
now we can use this in the program.
Requirement is to calculate the value of d value from the itab table.
d = b + c.
LOOP AT itab ASSIGNING < wa >.
< wa >-d = < wa >-b + < wa >-c.
*Here no need to write modify statement. Beacuse < wa >is a field symbol and it is pointing to memory of itab. If you modified < wa >, It automatically effected to the internal table itab.
ENDLOOP.

Sending mails from your application

Hello Friends,

Most of the times will get the requirement on this.
There are some predefined function modules to send the mail from SAP application.
Here i am explaining about the Function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
In this Function Module we need to pass some parameters,


CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = Z_DOC_DATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'

TABLES
PACKING_LIST = Z_TAB_PACK
* OBJECT_HEADER =
* CONTENTS_BIN =
CONTENTS_TXT = Z_TAB_TXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = Z_TAB_REC
* EXCEPTIONS
* TOO_MANY_RECEIVERS = 1
* DOCUMENT_NOT_SENT = 2
* DOCUMENT_TYPE_NOT_EXIST = 3
* OPERATION_NO_AUTHORIZATION = 4
* PARAMETER_ERROR = 5
* X_ERROR = 6
* ENQUEUE_ERROR = 7
* OTHERS = 8
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


Here
DOCUMENT_DATA is a structure ,

Z_DOC_DATA-DOC_SIZE = ( Z_TAB_LINES - 1 ) * 255 + STRLEN( Z_TAB_TXT ).
Z_DOC_DATA-OBJ_LANGU = SY-LANGU.
Z_DOC_DATA-OBJ_NAME = 'XYZ'.
Z_DOC_DATA-OBJ_DESCR = Z_V_SUB. " Subject line
Z_DOC_DATA-SENSITIVTY = 'F'.

There is a table called PACKING_LIST,

CLEAR : Z_TAB_PACK.
REFRESH : Z_TAB_PACK.
Z_TAB_PACK-TRANSF_BIN = SPACE.
Z_TAB_PACK-HEAD_START = 1.
Z_TAB_PACK-HEAD_NUM = 0.
Z_TAB_PACK-BODY_START = 1.
Z_TAB_PACK-DOC_TYPE = 'RAW'.
DESCRIBE TABLE Z_TAB_TXT LINES Z_TAB_PACK-BODY_NUM.
APPEND Z_TAB_PACK.
Then Recivers are :

* Add the recipients email address
CLEAR : Z_TAB_REC.
REFRESH : Z_TAB_REC.
Z_TAB_REC-RECEIVER = Z_V_EMAIL.
Z_TAB_REC-REC_TYPE = 'U'.
Z_TAB_REC-COM_TYPE = 'INT'.
Z_TAB_REC-NOTIF_DEL = 'X'.
Z_TAB_REC-NOTIF_NDEL = 'X'.
APPEND Z_TAB_REC.
You can send a mail to n number of recievers.
If you passed these parameters you will get the mail.
If you are not getting the mail, just run the BASIS transaction SCOT.

Then, Immediatly you will get the mail in to your mail box.


Thanks to all.

Please don't forget drop comments, Then only i can post more reliable