Hi Gaurav,
think about joins and not loops .
Assuming that you have your data of internal tables i_vbfa and i_vbrk available as tables in the procedure you can join the data of the tables and "calculate" the necessary flag.
Just a quick pseudo coding for the first read (cause I have no dev environment here at the moment).
lt_result =
SELECT
t1.field1 as field1,
t2.field2 as field2,
CASE WHEN t2.field1 <> '' AND t2.zzbelnr = '' THEN 'X' ELSE '' END as RBC
FROM :i_vbfa as t1 LEFT OUTER JOIN :i_fkdat as t2
ON t1.vbeln = t2.vbeln
AND t2.fkart = 'ZRBC';
The field in the " t2.field1 <> '' " check in the CASE expression should be a field in table t2 (i_fkdat) which is always filled to check that really a data record exists in that table (because of the left outer join all entries of table t1 (i_vbfa) are returned.
Regarding the CASE expression you can have a look to chapter 1.6 of the HANA SQL reference guide (http://help.sap.com/hana/SAP_HANA_SQL_and_System_Views_Reference_en.pdf).
You can also use CE functions CE_PROJECTION, CE_JOIN and CE_CALC (with IF function) to reach this and to avoid the switch between the SQL Engine and Calc. Engine in your procedure (just check the infos in the HANA SQLScript guide http://help.sap.com/hana/SAP_HANA_SQL_Script_Reference_en.pdf).
Best regards,
Florian