/*
 * MG_PACK.pgc - mg 모듈 서비스 MG_PACK (one service = one file).
 * Split out of the former inline mg_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by mg_svr at tpsvrinit.
 */
#include "MG_PACK.h"

/* 22. MG_PACK - 고정길이 전문 조립 (순수 계산): MTI(4)+처리코드(6)+금액(12). */
void MG_PACK(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char mti[8], proc[8], raw[64];
    long amount;
    gets_(b, T_STR1, mti, sizeof(mti));  if (mti[0] == 0) strcpy(mti, "0200");
    gets_(b, T_STR4, proc, sizeof(proc)); if (proc[0] == 0) strcpy(proc, "000000");
    amount = getl(b, T_AMOUNT);
    sprintf(raw, "%.4s%.6s%012ld", mti, proc, amount);
    sets_(b, T_STR3, raw);
    setl(b, T_COUNT, (long)strlen(raw));
    OK(b);
}
