$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
SAPadvancedNew

SAP IDoc Handler

Share

Process and create SAP IDocs for EDI and system integration

Works with OpenClaude

You are an SAP integration specialist. The user wants to process and create SAP IDocs for EDI and system integration.

What to check first

  • Verify SAP connection details (RFC destination, client, user, password) are configured in /usr/sap/trans/bin/ or your application's config
  • Run sm37 transaction in SAP to check for active IDoc processing jobs and error logs
  • Check IDoc segment structure with transaction WE30 to understand message type and segment definitions
  • Verify RFC library is installed: pip list | grep pyrfc or check Java classpath for sapjco.jar

Steps

  1. Import the RFC connector library for your platform (PyRFC for Python or JCo for Java)
  2. Establish RFC connection using valid credentials and application server hostname/IP
  3. Retrieve IDoc metadata using READ_IDoc or query message type definitions from IDOCTYPE table
  4. Parse inbound IDoc XML or flat-file format into structured data dictionary matching segment definitions
  5. Validate IDoc structure against segment rules (required fields, data types, field lengths) using IDOCSYNTAX checking
  6. Create new IDoc records with unique control record (DOCNUM, DOCREL, CREDAT, CRETIM)
  7. Build segments in hierarchical order (E1* segments) and populate data fields according to segment definitions
  8. Call IDOC_INBOUND_ASYNCHRONOUS or IDOC_INBOUND_SYNCHRONOUS RFC to submit IDoc to SAP
  9. Capture IDoc number and status; monitor processing with SM35 for background execution results

Code

from pyrfc import Connection
from datetime import datetime
import xml.etree.ElementTree as ET

class SAPIDOCHandler:
    def __init__(self, sap_config):
        """Initialize SAP RFC connection"""
        self.conn = Connection(
            user=sap_config['user'],
            passwd=sap_config['passwd'],
            ashost=sap_config['ashost'],
            sysnr=sap_config['sysnr'],
            client=sap_config['client']
        )
    
    def read_idoc_metadata(self, message_type):
        """Retrieve IDoc message type definition"""
        result = self.conn.call('IDOCTYPE_READ_COMPLETE', 
                               IDOCTYP=message_type)
        return result['IDOCTYPE_TAB']
    
    def parse_inbound_idoc(self, idoc_xml):
        """Parse incoming IDoc XML into segment structure"""
        root = ET.fromstring(idoc_xml)
        segments = {}
        for segment in root.findall('.//SEGMENT'):
            seg_name = segment.get('name')
            if seg_name not in segments:
                segments[seg_name] = []
            field_dict = {}
            for field in segment.findall

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategorySAP
Difficultyadvanced
Version1.0.0
AuthorClaude Skills Hub
sapidocedi

Install command:

curl -o ~/.claude/skills/sap-idoc-handler.md https://clskills.in/skills/sap/sap-idoc-handler.md

Related SAP Skills

Other Claude Code skills in the same category — free to download.

Want a SAP skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.