!--a11y-->
プログラミングの例
以下のセクションには、簡単な例だけが記載されています。詳細については、配布されている
RFC SDK の srfctest.c か sapinfo.c を参照してください。内部テーブルを転送する
RFC クライアントプログラムRFC_TABLE
tables[1]; /* 一つの内部データで動作 */RfcEnvironment
(...); /* エラー取り扱い機能インストール */rfc_handle =
RfcOpen (&rfc_opt); /* RFC 接続を開く */if (rfc_handle == RFC_HANDLE_NULL) /*
リターンコードをチェック */{
rfc_error_handling(
” RfcOpen ” ); /* RfcLastError によるエラー処理と */return 1; /*
エラー仕様の取得は、 */}
tables[0].name =
” ITAB1000 ” ; /* SAP-FM の定義と合わせる必要がある */if (rfc_rc != RFC_OK) /*
リターンコードをチェック */{
rfc_error_handling(
” RfcOpen ” ); /* RfcLastError で、 */}
fill_table
(table[0].ithandle, 10); /* 内部テーブルを */rfc_rc =
RfcCallReceive (...); /* 汎用モジュールのコール */if (rfc_rc != RFC_OK) /*
リターン・コードをチェック */{
rfc_error_handling(
” RfcCallReceive ” ); /* RfcLastError 経由で、 */}
ItDelete
( ...); /* 内部テーブルの保存域を開放 */RfcClose
(...); /* RFC 接続を閉じる */
/*
依頼どおりに内部テーブルをテキストで埋めるvoid
fill_table (ITAB_H itab_h, int table_leng){
if (table_leng == 0) return 0; /*
エントリのないテーブル */lineleng =
ItLeng (itab_h); /* テーブル行の長さを決定 */ for (linenr = 1; linenr <= table_leng; linenr++)
/*
{
ptr = (char *)
ItAppLine (itab_h);if (ptr == NULL) /*
リターンコードのチェック */{ /* エラーメッセージを出力 */
printf(
”\ nMemory insufficient\n ” ); /* output error message */exit(1); /*
プログラムを終了 */memcpy(ptr, table_data, lineleng); /*
内部テーブルに */ /* データを転送 */ }
return; /*
}
内部テーブルを受信
RFC クライアントプログラムRFC_TABLE
tables[1]; /* 一つの内部データで動作 */RfcEnvironment
(...); /* エラー取り扱い機能インストール */rfc_handle =
RfcOpen (&rfc_opt); /* RFC 接続を開く */if (rfc_handle == RFC_HANDLE_NULL) /*
リターンコードのチェック */{
rfc_error_handling(
” RfcOpen ” ); /* RfcLastError によるエラー処理と */return 1; /*
エラー仕様の取得 */}
tables[0].name =
” ITAB1000 ” ; /* SAP-FM の定義と */if (rfc_rc != RFC_OK) /*
リターンコードのチェック */{
rfc_error_handling(
” ItCreated ” ); /* RfcLastError で、 */}
rfc_rc =
RfcCallReceive (...); /* 汎用モジュールのコール */if (rfc_rc != RFC_OK) /*
リターンコードのチェック */{
rfc_error_handling(
” RfcCallReceive ” ); /* RfcLastError 経由で、 */}
display_table
(table[0].ithandle); /* 受信した内部テーブルを */ItDelete
( ...); /* 内部テーブルの保存域を開放 */RfcClose
(...); /* RFC 接続を閉じる */
/*
受信した内部テーブルを画面に表示 */void
display_table (ITAB_H itab_h){
lineleng =
ItLeng (itab_h); /* テーブル行の長さを取得 */for (linenr = 1; ; linenr++)
/* 内部テーブルでのループ */{
ptr = (char *)
ItGetLine (itab_h);if (ptr == NULL) break; /*
ヌル : テーブルの最後に到達 */ memcpy(table_data, ptr, lineleng);
/*
table_data[lineleng] =
’\ 0 ’ ; /* 文字列の最後を出力用に設定 */printf(
”’ %s ’\ n ” , table_data); /* 画面へ出力 */}
戻り値 ; /* メインプログラムに戻る */
}
