1 / 14

***** Function(RFC) 작성 방법 *****

***** Function(RFC) 작성 방법 *****. 1. Function Group 을 만든다. 2. 생성된 Function Group 에 Function Module 을 만든다. 3. Function Module 작성 3.1 Attributes 탭 작성. * Nomal Function Module 선택 : local 에서만 사용 가능 * Remote-Enabled Module 선택 : 다른 SAP 서버 / 이기종 서버와의 인터페이스 가능 (RFC).

thom
Télécharger la présentation

***** Function(RFC) 작성 방법 *****

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ***** Function(RFC) 작성 방법 ***** 1. Function Group을 만든다.

  2. 2. 생성된 Function Group에 Function Module을 만든다.

  3. 3. Function Module 작성 3.1 Attributes 탭 작성 * Nomal Function Module 선택 : local에서만 사용 가능 * Remote-Enabled Module 선택 : 다른 SAP서버/이기종 서버와의 인터페이스 가능(RFC)

  4. 3. Function Module 작성 3.2 import 탭 작성 - 외부로부터 입력 받을 파라메터(변수)들에 대한 설정을 한다. 디폴트로 파라메터가 아니라, 선택적 입력 파라메터인 경우 체크해준다. RFC로 작성시는 반드시 체크해 줘야 함. 체크 안하면 오류 메시지창 뜸.

  5. RFC로 작성시는 반드시 체크해 줘야 함. 체크 안하면 오류 메시지창 뜸. 3. Function Module 작성 3.3 export 탭 작성 - 결과값으로 내보낼 파라메터들에 대한 설정을 한다.

  6. 디폴트로 파라메터가 아니라, 선택적 입력 파라메터인 경우 체크해준다. 3. Function Module 작성 3.4 Tables 탭 작성 - function module에서 사용할 테이블에 대한 설정을 한다. - 테이블은 입력 파라메터로 쓰일수도 출력 파라메터로 쓰일 수도 있음(PERFORM문에서 사용되는 이치와 같음).

  7. 3. Function Module 작성 3.5 Exceptions 탭 작성 - 예외(오류)처리에 대한 설정을 한다. - 예외는 Raise문을 이용해 발생 시킨다(다음장의 소스를 참고할것.)

  8. 3. Function Module 작성 3.6 Source code 탭 작성 : 설정된 파라메터들을 이용해 프로그래밍을 한다. FUNCTION ZTEST_FUNCTION_MODULE_01. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(INPUT1) TYPE I OPTIONAL *" VALUE(INPUT2) TYPE I OPTIONAL *" VALUE(STATUS) TYPE ZZSTATUS_KJL OPTIONAL *" VALUE(CARRID) TYPE ZFLIGHT_KJL-CARRID OPTIONAL *" EXPORTING *" REFERENCE(OUTPUT) TYPE P *" REFERENCE(OUTVALUE) TYPE CHAR10 *" TABLES *" ITAB STRUCTURE ZFLIGHT_KJL OPTIONAL *" EXCEPTIONS *" NOTFOUND *" OTHERS *"---------------------------------------------------------------------- OUTPUT = INPUT1 * INPUT2. IF STATUS = '1'. OUTVALUE = 'ING'. ELSEIF STATUS = '2'. OUTVALUE = 'COMP'. ENDIF. SELECT * FROM SFLIGHT INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE CARRID = CARRID. IF SY-SUBRC <> 0. RAISE NOTFOUND.“Exception 발생 ENDIF. ENDFUNCTION.

  9. 4. Program에서 작성된 Function Module을 사용하는 예제. IF sy-subrc = 1. MESSAGE i888(sabapdocu) WITH 'NOTHING'. ELSEIF sy-subrc = 2. MESSAGE i888(sabapdocu) WITH 'OTHERS ERROR!'. ENDIF. WRITE:/ p_input1, ' * ' , p_input2, ' = ', g_output, :/ 'STATUS : ', p_status, '(', g_outvalue, ')'. DESCRIBE TABLE it_flight LINES sy-tfill. “자세한 내용은 <참고>에… SKIP. IF sy-tfill <> 0. LOOP AT it_flight INTO wa_flight. WRITE:/ wa_flight-carrid, 10 wa_flight-connid, 20 wa_flight-fldate, 30 wa_flight-price, 50 wa_flight-seatsmax, 60 wa_flight-seatsocc. ENDLOOP. ENDIF. * IF IT_FLIGHT[] IS INITIAL. “자세한 내용은 <참고>에… * ENDIF. *&-----------------------------------------------------* *& *& Report ZTEST_FUNCTION_MODULE_01 *& *& < FUNCTION MODULE을 이용하는 프로그램 만들기 예 > *& - Function Module을 불러올때는 Pattern 버튼을 클릭하여 불러옴. *& - Function Module에 있는 변수의 갯수와 타입을 받드니 맞춰서 *& 넘겨주고 받아야함. *& *&-----------------------------------------------------* REPORT ztest_function_module_01. DATA: g_output TYPE p, g_outvalue(10) TYPE c. DATA: it_flight TYPE TABLE OF zflight_kjl, wa_flight TYPE zflight_kjl. PARAMETERS: p_input1 TYPE i, p_input2 TYPE i, p_status LIKE zflight_kjl-status, p_carrid LIKE zflight_kjl-carrid. START-OF-SELECTION. * Function의 call은 pattern 버튼을 클릭…. CALL FUNCTION 'ZTEST_FUNCTION_MODULE_01' EXPORTING input1 = p_input1 input2 = p_input2 status = p_status carrid = p_carrid IMPORTING output = g_output outvalue = g_outvalue TABLES itab = it_flight EXCEPTIONS notfound = 1 others = 2. ************************************************************ * <참고> SELECT의 결과가 있는지 없는지 확인하는 방법 ************************************************************ * * 1. DESCRIBE TABLE 오브젝트 LINES 정수형변수 * - 인터널테이블의 라인수를 구하는 방법으로 sy-tfill의 값이 * 0보다 큰지 IF문으로 비교해보면 알 수 있다. * 2. IF IT_FLIGHT[] IS INITIAL. * ENDIF. * - 오브젝트가 INITIAL상태인지 검사해본다. * ************************************************************

  10. 제목: [완료]rfc에서 import의 optional과 passvalue의 체크박스 기능에 대해.. [5] [2008-01-04 16:53] • 작성자: 풍뎅이 • IP: 58.103.***. | PL: 1143 답변:30 • 조회: 102 | 추천: 7 레벨:7 • <table width='100%' height='100%' border='0' cellpadding='2' cellspacing='0' style='word-break:break-all;'><tr><td align='center'>안녕하세요. 반갑습니다. </td></tr></table> • rfc에서 import의 • optional과 passvalue의 체크박스 기능에 대해서 알고 싶습니다. • 초보인지라 기존의 프로그램을 수정시 기존자료와 동일하게 처리했는데요.. • 체크하는 항목과 하지 않아도 되는 항목에 대해 설명해 주시면 감사드리겠습니다. • 고수님들의 의견을 부탁드리겠습니다. • e-abap | IP: 211.181.***. | PL: 6861 | 답변지수: 68 | 레벨: 1 [2008-01-07 09:48] • 1. optional • - import 파리미터를 필수 사항으로 할 것인지를 선택하게 됩니다. • 즉 체크하게 되면, 프로그램에서 호출할때 반드시 파라미터를 설정해야 합니다. • 2. pass value • - import 파라미터는 기본적으로 function module 내에서 수정이 불가능하지만, • 해당 옵션을 선택하면 함수내에서 변경이 가능합니다. • 해당 옵션을 체크하게 되면, call by value 로 호출하기 때문에 • 호출한 프로그램과 호출당한 프로그램 사이에 각가의 메모리를 변수에서 작업을 하게 됩니다. • rfc는 원격에 있는 시스템이기 때문에 변수는 반드시 pass value를 선택해서 각각의 메모리 영역에서 변수를 선언해서 사용하도록 • pass value 옵션을 선택해야 합니다. • Web In Abap | IP: 210.94.***. | PL: 1339 | 답변지수: 80 | 레벨: 2 [2008-01-07 14:24] • 우잉... 관리자님 1번에 옵션은 체크를 해 주면 넣어도 그만 안 넣어도 그만 체크가 없으면 무조건 필수로 입력해야 하는 파라미터 설정 아닌가요??? 반대로 얘기 하신거 같은데... 제가 잘못 알고 있는건가 ㅡㅡㅋ rfc는 pass value에 체크를 빼면 에러납니다. 원격지에서 C?하는 거기 때문에 반드시 pass value 체크를 해야 액티브가 되죠~ • e-abap | IP: 211.181.***. | PL: 6861 | 답변지수: 68 | 레벨: 1 [2008-01-07 14:29] • 예 맞습니다. 그런 의미로 적은 겁니다. • 풍뎅이 | IP: 58.103.***. | PL: 1143 | 답변지수: 30 | 레벨: 7 [2008-01-14 11:01] • 관리자님 Web In Abap님 답변 감사드립니다. • 루자빗 | IP: 211.219.***. | PL: 379 | 답변지수: 12 | 레벨: 7 [2008-02-09 15:11] • 덕분에 개념잡는데 도움이 되었습니다.

  11. 제목: RFC에 대한 자료를 요청합니다. 도무지 감이 안 잡히네요.[5][2007-04-16 13:40] 작성자:이종원IP: 211.54.***.|PL: 385 답변:7 조회: 466|추천: 131 레벨:7 • RFC에 대한 자료 요청합니다. • 현재 RFC 개념을 잡아볼려고 하는데 생각보다 쉽지 않네요. • 개념 잡는데 도움을 주셨으면 좋겠씁니다. 자료가 있으면 더 좋구요. • 그리고 RFC 샘플 코드를 보고 싶은데 실력있는 아밥퍼 님들의 도움을 요청합니다. • 그럼 즐거운 한주 되십시오. e-abap|IP: 211.181.***.|PL: 6861|답변지수: 68|레벨: 1 [2007-04-16 13:44] • RFC는 그냥 함수와 동일합니다. • 다만 외부에서 호출할수 있도록 SE37애서 함수 속성 탭의 • REMETE-ENABLED MODULE 이 체크되면 됩니다. • 이것이 체크되어 있으면, 다른 R/3 서버에서 호출하거나 EAI서버등에서 호출할수 있습니다. e-abap|IP: 211.181.***.|PL: 6861|답변지수: 68|레벨: 1 [2007-04-16 13:46] • http://ecbase.dyndns.org/zb/bbs/zboard.php?id=onepaper&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=130 • 참고하세요. 이종원|IP: 211.54.***.|PL: 385|답변지수: 7|레벨: 7 [2007-04-16 13:56] • 감사합니다....저도 그정도 개념은 알고 있는데요. 실질적으로 해본적도 없구....다른 시스템과 디비 연동같은것도 해보적이 없어서.........궁금해서 올려습니다. • 만일 sapDB 내용을 다른 시스템에서 불러와야 한다면....함수를 어떻게 구성하면 됩니까? • 그냥...select문을 사용해서 내용을 인터널테이블에 담아주기만 한다면 다른 시스템에서 그 테이블을 읽어들이는 방식으로 진행되는건가요? • 그냥 저의 생각인데 로직이 궁금해서요. e-abap|IP: 211.181.***.|PL: 6861|답변지수: 68|레벨: 1 [2007-04-16 14:00] • 예 맞습니다. 일반적으로 인터페이스는 중간에 시스템이 더 존재하는 방식을 사용합니다. • r/3에서는 인터널 테이블에 데이터만 리턴하면 eai에서 알아서 받아갑니다. • 일반 함수와 차이가 없다고 생각하시면 됩니다. e-abap|IP: 211.181.***.|PL: 6861|답변지수: 68|레벨: 1 [2007-04-16 15:04] • http://ecbase.dyndns.org/zb/bbs/zboard.php?id=onepaper&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=131 • 참고해보세요~

  12. Dynamic Internal TableSubramanian VenkateswaranCompany: L&T InfotechNov. 19, 2004 11:45 PMPermalinkOn searching the ABAP forums, I did find many queries (in fact, there were a few queries last week as well) to create a dynamic internal table. I have identified a couple of scenarios and methods by which we can create a dynamic internal table.Tools RequiredKnowledge on data references, field-symbols is an added advantage, as theyare extensively used in all the approaches.Create a Dynamic Internal TableScenario 1-------------------------------------Assuming, in an internal table, you have entries of field names, which should be present as columns of a dynamic internal table.For e.g. we have an internal table, LT_INTERNALTABLE.Entries in LT_INTERNALTABLE are:FIELDNAME MANDT CARRID CONNID FLDATE PRICE CURRENCY To be converted toMANDT CARRID CONNID FLDATE PRICE CURRENCY 100 LH 0400 28.02.1995 899 DEM 100 LH 0454 17.11.1995 1499 DEM Data Definition*** TablesDATA: LT_DATA type ref to DATA.DATA: LT_FIELDCATALOG type LVC_T_FCAT.*** StructureDATA: LS_FIELDCATALOG type LVC_S_FCAT.*** Data ReferencesDATA: NEW_LINE type ref to data.*** Field SymbolsFIELD-SYMBOLS: <FS_DATA> type ref to DATA, <FS_1> type any table, <FS_2>, <FS_3>.Populating the internal table with fieldnames required for our dynamic internal table LS_FIELDCATALOG-FIELDNAME = 'MANDT'. append LS_FIELDCATALOG to LT_FIELDCATALOG.LS_FIELDCATALOG-FIELDNAME = 'CARRID'. "FieldnameLS_FIELDCATALOG-INTTYPE = 'C'. "Internal Type C-> Characterappend LS_FIELDCATALOG to LT_FIELDCATALOG.LS_FIELDCATALOG-FIELDNAME = 'CONNID'.LS_FIELDCATALOG-INTTYPE = 'N'.append LS_FIELDCATALOG to LT_FIELDCATALOG.LS_FIELDCATALOG-FIELDNAME = 'FLDATE'.LS_FIELDCATALOG-INTTYPE = 'D'.append LS_FIELDCATALOG to LT_FIELDCATALOG.LS_FIELDCATALOG-FIELDNAME = 'PRICE'.LS_FIELDCATALOG-INTTYPE = 'P'.append LS_FIELDCATALOG to LT_FIELDCATALOG.LS_FIELDCATALOG-FIELDNAME = 'CURRENCY'.LS_FIELDCATALOG-INTTYPE = 'C'.append LS_FIELDCATALOG to LT_FIELDCATALOG.Assigning Field-Symbol to our dynamic internal tableassign LT_DATA to <FS_DATA>.Calling the method CREATE_DYNAMIC_TABLEcall method cl_alv_table_create=create_dynamic_table exporting it_fieldcatalog = LT_FIELDCATALOG importing ep_table = FS_DATA exceptions generate_subpool_dir_full = 1 others = 2.if sy-subrc <> 0.endif.Internal Table is ready, now to put data in that tableIf you check the field-symbol, <FS_DATA>, it now refers to dynamic internaltable that you wanted to create at start.Next steps are to put data inside. For this, we first assign the data contentsof <FS_DATA> to a field-symbol <FS_1>.*** So <FS_1> now points to our dynamic internal table.assign <FS_DATA>->* to <FS_1>.*** Next step is to create a work area for our dynamic internal table.create data NEW_LINE like line of <FS_1>.*** A field-symbol to access that work areaassign NEW_LINE->*to <FS_2>.*** And to put the data in the internal tableselect MANDT CARRID CONNID FLDATE PRICE CURRENCYfrom SFLIGHTinto corresponding fields of table <FS_1>.*** Access contents of internal tableloop at <FS_1> assigning <FS_2>.assign component 1 of structure <FS_2> to <FS_3>.write: / <FS_3>.endloop.Scenario 2In case you know the name of the DDIC structure, then it becomes all the more simple. data: lv_tablename type string value 'SFLIGHT'.data: lv_dref type ref to DATA.CREATE DATA lv_dref type table of (lv_tablename).FIELD-SYMBOLS: <FS> TYPE STANDARD TABLE.ASSIGN lv_dref->* TO <FS>.select *from sflightinto table <FS>.WAS 6.40 Approach ----------------------------------------------Thomas Jung shares with us the approach that can be used in WAS 6.40 , which is more elegant and it removes some of the issues associated with cl_alv_table_create. report yes_tjung_sflight_test.*** Data Declarationdata: sflighttype type ref to cl_abap_structdescr,tabletype type ref to cl_abap_tabledescr,comp_tabtype cl_abap_structdescr=>component_table,new_comp_tab like comp_tab,linetype type ref to cl_abap_structdescr,dref type ref to data.*** Field Symbolsfield-symbols: <wa_comp> like line of comp_tab.field-symbols: <table> type any table.sflighttype ?= cl_abap_typedescr=>describe_by_name('SFLIGHT').comp_tab = sflighttype->get_components( ).loop at comp_tab assigning <wa_comp>.case <wa_comp>-name.when 'CARRID' or 'CONNID' or 'FLDATE' or 'PRICE' or 'CURRENCY'.append <wa_comp> to new_comp_tab.endcase.endloop.linetype = cl_abap_structdescr=>create( new_comp_tab ).tabletype = cl_abap_tabledescr=>create(p_line_type = linetypep_table_kind = cl_abap_tabledescr=>tablekind_std ).create data dref type handle tabletype.assign dref->* to <table>.select * from sflight into corresponding fields of table <table>.field-symbols: <wa_data> type any.field-symbols: <wa_field> type any.loop at <table> assigning <wa_data>.write: /.loop at new_comp_tab assigning <wa_comp>.assign component sy-tabix of structure <wa_data> to <wa_field>.write: <wa_field>.endloop.endloop.For more see the comments section of this weblog, you may also find the Dynamic Function Module Interface. Also check this section of the comments, where Thomas Jung shares some important information from developers perspective : https://weblogs.sdn.sap.com/cs/user/view/cs_msg/1599 Dynamic Function Module Parameter Creation------------------------------------------------------2004-11-15 06:28:52 Thomas Jung [Reply]While we are on the subject of dynamic internal table creation; here is another method. I have used this in 620 to dynamically create data areas for making RFC calls to a 46C system. I read the data type from the function Interface and then use the CREATE DATA statement. Also included are the exceptions you will probably want to catch any bad casts. ****Dynamically read the interface of the function module we are going ****to calldata: irfc type table of rfc_fint_p.field-symbols: <wa_rfc> like line of irfc.call function 'RFC_GET_FUNCTION_INTERFACE_P'destination me->rfcdestexportingfuncname = me->rfcfunctiontablesparams_p = irfcexceptionsfu_not_found = 1nametab_fault = 2others = 3.if sy-subrc <> 0.me->message = 'Unable to read function interface'(e05).exit.endif.****Read the datatype of the IDATA Exporting Parameterread table irfc assigning <wa_rfc>with key paramclass = 'E' "Exportingparameter = 'IDATA'.if sy-subrc ne 0.me->message = 'Specified RFC Exit does not have the correct interface'(e06).exit.endif.data_type = <wa_rfc>-tabname.****We need a DataTypeif data_type is initial.me->message = 'Data Type of Value Help can not be blank'(e02).exit.endif.****Create a Importing Parameter for the DataType Specifieddata: error1 type ref to cx_sy_create_data_error .try.create data me->idata type (data_type).catch cx_sy_create_data_error into error1.me->message = error1->get_text( ).exit.endtry.data: error2 type ref to cx_sy_assign_cast_illegal_cast.data: error3 type ref to cx_sy_assign_cast_unknown_type .try.field-symbols: <tab1> type standard table.assign me->idata->* to <tab1>.catch cx_sy_assign_cast_illegal_cast into error2.me->message = error2->get_text( ).exit.catch cx_sy_assign_cast_unknown_type into error3.me->message = error3->get_text( ).exit.endtry.Dynamic Internal Table in 640---------------------------------------------------------------------2004-11-15 05:38:35 Thomas Jung [Reply]Since you mentioned that this can be done easier in 640, I thought I might share this 640 code sample. In 640 we have public classes and kernel support instead of dynamically generated code inside cl_alv_table_create. This give greater flexibility.report yes_tjung_sflight_test.data: sflighttype type ref to cl_abap_structdescr,tabletype type ref to cl_abap_tabledescr,comp_tab type cl_abap_structdescr=>component_table,new_comp_tab like comp_tab,linetype type ref to cl_abap_structdescr,dref type ref to data.field-symbols: <wa_comp> like line of comp_tab.field-symbols: <table> type any table.sflighttype ?= cl_abap_typedescr=>describe_by_name('SFLIGHT').comp_tab = sflighttype->get_components( ).loop at comp_tab assigning <wa_comp>.case <wa_comp>-name.when 'CARRID' or 'CONNID' or 'FLDATE' or 'PRICE' or 'CURRENCY'.append <wa_comp> to new_comp_tab.endcase.endloop.linetype = cl_abap_structdescr=>create( new_comp_tab ).tabletype = cl_abap_tabledescr=>create(p_line_type = linetypep_table_kind = cl_abap_tabledescr=>tablekind_std ).create data dref type handle tabletype.assign dref->* to <table>.select * from sflight into corresponding fields of table <table>.field-symbols: <wa_data> type any.field-symbols: <wa_field> type any.loop at <table> assigning <wa_data>.write: /.loop at new_comp_tab assigning <wa_comp>.assign component sy-tabix of structure <wa_data> to <wa_field>.write: <wa_field>.endloop.endloop.

More Related