If I understand correctly, you need to do a full outer join (in SQ or Joiner) on A_id=B_id. Then you can derive the target fields in an expression transformation by doing some null checking as follows:
tgt_id: IIF(ISNULL(A_id),B_id, A_id)
tgt_code: IIF(ISNULL(A_code), B_code, A_code)
is_table_A: IIF(ISNULL(A_id),'0','x')
is_table_B: IIF(ISULL(B_id), '0', 'x')