Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom RFC

former_member290321
Participant
0 Kudos

I am not a ABAP developer but working on MS SQL 2005 BI side but I need something like this from ECC 6.0

I will request if anyone can guide me building a custom RFC with simple select statment

i.e.

select * from Table_Name

where Field_Name between @StartDateofLastMonth and @EndDateofLastMonth.

The aforesaid select statment will get the calculated startdate and enddate from sap system date.

where as i have to give @Table_Name and @Field_Name from my end as variable...

One more favor where i can get sample RFC for the aforesaid.

3 REPLIES 3

Former Member
0 Kudos

>

Hi,

if it is really that simle you may use function module RFC_READ_TABLE. Reads any table of the system.

Unfortunately the documentation is available in German only. But the interface explains it sufficiently:

*"  IMPORTING
*"     VALUE(QUERY_TABLE) "table name
*"     VALUE(DELIMITER)   "delimeter for output - default is space
*"     VALUE(NO_DATA)     "retrieve field list only
*"     VALUE(ROWSKIPS)    "skips some rows - no ned to use so far
*"     VALUE(ROWCOUNT)    "max. no of selected rows
*"  TABLES
*"      OPTIONS           "WHERE CLAUSE (ABAP OPEN SQL )
*"      FIELDS            "First 30 characters for desired output fields 
*"      DATA              "selected data sepearated by DELIMETER

example:

FORM data_select  USING    pp_matnr TYPE matnr.
    CONSTANTS c_delim LIKE  sonv-flag VALUE '|'.
    DATA: lt_options TYPE STANDARD TABLE OF rfc_db_opt WITH HEADER LINE,
         lt_data  TYPE STANDARD TABLE OF tab512 WITH HEADER LINE.

    DATA: lt_split TYPE STANDARD TABLE OF
                                       catpaval WITH HEADER LINE.
    FIELD-SYMBOLS <l_value>.
    REFRESH: lt_options, lt_data.

    CONCATENATE '''' pp_matnr '''' INTO lt_options.
    CONCATENATE 'MATNR EQ' lt_options INTO lt_options
            SEPARATED BY space.
    APPEND lt_options.
    CONCATENATE '''' p_valdat '''' INTO lt_options.
    CONCATENATE 'AND VALTO GE ' lt_options INTO lt_options
            SEPARATED BY space.
    APPEND lt_options.

    APPEND LINES OF gt_options TO lt_options. "filled elsewhere
    

    REFRESH lt_data.
    CALL FUNCTION 'RFC_READ_TABLE'
      DESTINATION gv_dest          "RQ 2429143 <ins>
*      DESTINATION p_logsys        "RQ 2429143 <del>
      EXPORTING
        query_table                = 'DGTMD'
   delimiter                  = c_delim
*   NO_DATA                    = ' '
*   ROWSKIPS                   = 0
*   ROWCOUNT                   = 0
      TABLES
        options                    = lt_options
        fields                     = gt_fields
        data                       = lt_data
    EXCEPTIONS
      table_not_available        = 1
      table_without_data         = 2
      option_not_valid           = 3
      field_not_valid            = 4
      not_authorized             = 5
      data_buffer_exceeded       = 6
      OTHERS                     = 7
                 .
    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.                    " data_select

Have fun,

Holger

HP

Edited by: Holger Pakirnus on Jun 26, 2008 6:57 PM

0 Kudos

The problem with RFC_READ_TABLE is that i can't use variable in @OPTIONS from MS SQL server side.

So I can't auto my package to import data on monthly basis.

I can't use this in filter in@OPTIONS

i.e.

@OPTIONS = 'where ce1lsc0.budat between @startdateoflastmonth and @lastdateoflastmonth '

0 Kudos

as you fill the options in your external system, you can calculate the two dates there - format has to be YYYYMMDD. Can't see any problem.

Kind regards,

HP